Mahamudul Hasan Rubel
HomeBlogCoursesAboutProjectsSkillsExperiencePhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • Blog
  • Courses
  • About
  • Projects
  • Skills
  • Experience
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
Lesson 46 of the React Fundamentals: Build Modern UIs from Scratch course
ReactJune 25, 20264 min read

Debugging React Apps: A Professional Guide to Troubleshooting

Master debugging React apps with React DevTools. Learn to inspect state, trace props, and profile performance to fix bugs in your movie browser project.

ReactdebuggingReact DevToolstroubleshootingperformancejavascriptfrontend

Previously in this course, we explored introduction to testing to catch regressions automatically. While automated tests are vital, you’ll inevitably face scenarios where the UI isn't behaving as expected during manual exploration. In this lesson, we move from testing to debugging, specifically focusing on how to inspect and diagnose your application's internal state and performance using professional tooling.

The Power of React DevTools

When you are building a complex UI like our movie browser, the standard browser console is rarely enough. While console.log() has its place, it becomes noisy and cluttered when you need to track state across dozens of components.

The React DevTools browser extension is the single most important tool in your kit. Once installed, it adds two new tabs to your browser’s inspection pane: Components and Profiler.

Inspecting State and Props

The "Components" tab displays the current hierarchy of your React app. It mirrors your JSX structure, allowing you to click on any component to see:

  1. Props: What data was passed in from the parent.
  2. State: The current values held by useState hooks.
  3. Hooks: A list of active hooks (like useEffect or useContext) and their current values.

Pro-tip: You can click the "eye" icon to inspect a component in the console, which makes the component instance available as a global variable $r. You can then inspect its props and state directly in the console using $r.props or $r.state.

Identifying State Issues

State bugs are the most common source of frustration in React development. If your movie browser isn't updating the search results, the issue is almost always a mismatch between what you think the state is and what it actually is.

Let's look at a common scenario in our project where a filter toggle fails to update the list:

JAVASCRIPT
// A common mistake in our MovieList component
const [filter, setFilter] = useState(false);

const handleToggle = () => {
  // Bug: We are passing a static value instead of a functional update
  setFilter(!filter); 
  console.log("Filter is now:", filter); // This will log the OLD value!
};

If you use React DevTools, you don't need to guess. Select the MovieList component in the DevTools tree. You can manually edit the filter state value right in the sidebar to see if the UI updates correctly. If the UI changes when you flip the switch in DevTools but fails when you click the button, you know your handleToggle logic is the culprit.

Profiling Component Performance

Once your app is functional, you'll want to ensure it’s performant. As we learned in React performance debugging: How to trace component re-renders, unnecessary re-renders are the silent killers of user experience.

The Profiler tab in React DevTools allows you to record a "session" of your app.

  1. Click the "Record" button (the circular icon).
  2. Perform the action (e.g., typing in the search bar).
  3. Stop the recording.

React will generate a flame graph showing exactly which components rendered and why. If a component rendered, the profiler will tell you if it was due to a prop change, a state change, or a parent re-render. This is invaluable when you've finalized the movie browser and notice it feels sluggish.

Hands-on Exercise: Inspecting the Movie Browser

  1. Open your movie browser project in your browser.
  2. Open React DevTools and find your MovieCard components.
  3. Select a card and verify its props (like title and posterUrl).
  4. Trigger a search action. Watch the "Components" tree highlight in green; this indicates the component is re-rendering.
  5. If you find a component that re-renders but doesn't actually change visually, record a session in the Profiler to identify the trigger.

Common Pitfalls

  • Trusting the Console Too Soon: Beginners often log state immediately after calling setState. Remember that state updates are asynchronous; the log will reflect the previous state, not the updated one. Use the DevTools UI instead.
  • Ignoring the "Why": When performance profiling, don't just look for what is slow. Look at the "Why did this render?" section in the Profiler. Often, you'll find that a component is re-rendering because it's receiving a new object reference every time the parent renders—a classic bug that can be fixed with useMemo.
  • Component Over-nesting: If your folder structure is clean but your component tree in DevTools looks like a "spaghetti" of providers, you might be over-complicating your state architecture.

Recap

Debugging is an iterative process of elimination. Start by verifying your data flow with the Components tab, then use the Profiler to ensure your rendering logic is efficient. By mastering these tools, you move from "guessing" why a bug exists to "observing" the exact state of your application.

Up next: We will move to the final stages of your project by learning about Deployment Basics, where you'll take your local movie browser and put it live on the web.

Previous lessonIntroduction to TestingNext lesson Deployment Basics
Back to Blog

Similar Posts

ReactReactJune 25, 20263 min read

Fetching Data from an API: A Practical React Guide

Master the fetch API in React to retrieve external data. Learn to perform asynchronous requests and store JSON responses in your component state effectively.

Read more
ReactReactJune 25, 20263 min read

Part of the course

React Fundamentals: Build Modern UIs from Scratch

beginner · Lesson 46 of 49

  1. 1

    Introduction to Component-Based Architecture

    4 min
  2. 2

    Understanding the Virtual DOM

    4 min
  3. 3

    Setting Up with Vite

    3 min

Building a Movie Filter Toggle in React: A Beginner's Guide

Master the art of UI state management by adding a filter toggle to your movie app. Learn to control list rendering using boolean state and checkbox inputs.

Read more
ReactReactJune 25, 20264 min read

Rendering Lists of Data in React: A Practical Guide

Learn how to use the map method for list rendering in React. Master the key prop to keep your dynamic movie lists efficient, performant, and bug-free.

Read more
4

Mastering JSX Syntax

4 min
  • 5

    Creating Static Components

    3 min
  • 6

    Styling Components

    3 min
  • 7

    Passing Data with Props

    3 min
  • 8

    Dynamic Movie Cards

    3 min
  • 9

    Component Composition

    3 min
  • 10

    Conditional Rendering

    3 min
  • 11

    Rendering Lists of Data

    4 min
  • 12

    The Key Prop Explained

    4 min
  • 13

    Introduction to React State

    4 min
  • 14

    Managing State with useState

    3 min
  • 15

    Building an Interactive Search Bar

    3 min
  • 16

    Handling Click Events

    4 min
  • 17

    Updating State Based on Previous State

    4 min
  • 18

    Filtering the Movie List

    3 min
  • 19

    Handling Form Submissions

    3 min
  • 20

    Controlled Components

    4 min
  • 21

    Event Bubbling and Propagation

    3 min
  • 22

    Building a Movie Filter Toggle

    3 min
  • 23

    Introduction to Side Effects

    4 min
  • 24

    useEffect Dependencies

    4 min
  • 25

    Fetching Data from an API

    3 min
  • 26

    Handling Loading States

    3 min
  • 27

    Managing Errors

    3 min
  • 28

    Cleanup Functions in useEffect

    3 min
  • 29

    Debouncing Search Input

    3 min
  • 30

    Refactoring for Clean Code

    3 min
  • 31

    Folder Structure Best Practices

    4 min
  • 32

    Extracting Custom Hooks

    3 min
  • 33

    Prop Drilling and Context API

    3 min
  • 34

    Polishing the UI

    3 min
  • 35

    Finalizing the Movie Browser

    3 min
  • 36

    Review of Component Lifecycle

    4 min
  • 37

    Review of State Management

    4 min
  • 38

    Building a Modal Component

    3 min
  • 39

    Introduction to PropTypes

    3 min
  • 40

    Performance Optimization Basics

    3 min
  • 41

    Handling Browser History

    3 min
  • 42

    Working with LocalStorage

    3 min
  • 43

    Building a Favorites List

    3 min
  • 44

    Handling Media in React

    3 min
  • 45

    Introduction to Testing

    4 min
  • 46

    Debugging React Apps

    4 min
  • 47

    Deployment Basics

    3 min
  • 48

    Using External Libraries

    3 min
  • 49

    Advanced

    3 min
  • View full course