Sub topic 1
What React Developer Tools Shows That Browser Tools Do Not
Prerequisites
You should be able to write React function components, use useState, pass props, run a React app locally, and use the browser’s Elements and Console panels.
React-Aware Debugging
Browser developer tools show the rendered HTML, JavaScript, network requests, and runtime errors. They do not normally show how that HTML came from React components.
React Developer Tools adds a React-specific view. It shows the component tree, including components that render no visible HTML. You can select a component and inspect its props, state, and hooks. This helps you ask whether a bug comes from incorrect data, local state, or the component structure.
Installing the Extension and Opening the Tabs
Install React Developer Tools from the extension store for Chrome, Edge, or Firefox. Start your React app in development mode, then open the browser developer tools.
You should see Components and Profiler tabs. The Components tab is for inspecting the current tree and values. The Profiler records rendering activity so you can investigate performance.
If the tabs do not appear, confirm that the page contains a React app and that the extension is enabled. Production builds may expose less debugging information. Use a development build while learning and debugging.
> callout note > React Developer Tools inspects React’s component model. The Elements panel inspects the final DOM. A component can exist without creating a corresponding DOM element.
Navigating the Component Tree
Open Components and expand the tree from the application root. Select a component to view its details. Parent and child relationships show how data and rendering flow through the app.
Use the search box when the tree is large. Select a component that displays the incorrect value, then move upward to inspect the data source and downward to inspect its children.
Inspecting Props, State, and Hooks
The details pane lists a selected component’s props and state. Props are values received from a parent. State is data owned by the component. Hooks are functions such as useState that let function components use React features.
Expand each value and compare it with what the screen displays. For a hook, check both its current value and the component that owns it. This often reveals a stale prop, an unexpected state value, or a child receiving the wrong data.
Exercise
Which tool should you use first when you need to know why a component received the wrong value: the Elements panel or the Components tab?
Show answer
Use the Components tab. It shows the component’s props, state, and hooks, while Elements shows only the rendered DOM.