Sub topic 2
Installing the extension and opening the tabs
This chapter assumes you can write React function components, use useState and props, and open the browser's Elements and Console panels. You also need an app you can run locally in development mode. Here you install React Developer Tools, confirm it detects your app, and find its two tabs.
Installing the extension
React Developer Tools is a browser extension. Install it from your browser's official store:
- Chrome: the Chrome Web Store, listed as "React Developer Tools".
- Firefox: Firefox Add-ons.
- Edge: Edge Add-ons.
After installing, pin the extension to the toolbar so you can see its icon. Safari has no extension, so use the standalone package covered in a later chapter.
Two browser settings often block the extension:
- Local files. If you open an HTML file with a
file://address, enable "Allow access to file URLs" on the extension's details page. Pages served fromlocalhostdo not need this. - Private windows. Extensions are off in incognito or private windows by default. Enable the extension for them in the extension settings if you need it there.
A page to test with
Any React app works. This minimal component gives you something to inspect:
import { useState } from 'react';
export function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Clicked {count} times
</button>
);
}Start your dev server and open the app. If you installed the extension while the page was already open, reload the page. The extension attaches to a page when it loads.
Reading the toolbar icon
The icon tells you what the extension found on the current page:
| Icon state | Meaning |
|---|---|
| Grey or disabled | No React detected on this page |
| Colored | React found, running a development build |
| Dark | React found, running a production build |
A production build gives you less information. Later chapters cover what changes and how to profile it.
Opening the tabs
Open the browser's developer tools with F12, Ctrl+Shift+I (Windows and Linux), or Cmd+Option+I (macOS). Two new tabs appear next to Elements and Console:
- Components shows the React component tree, plus the props, state, and hooks of the component you select.
- Profiler records renders and shows how long each one took and why it happened.
If the panel is narrow, the tabs may be hidden behind the » overflow menu. Widen the panel or dock it to the side.
Common problems
- The tabs do not appear. Reload the page, then close and reopen DevTools. This fixes most cases.
- The icon is grey on a React app. The app may render inside an iframe. Open the iframe's address directly, or choose its frame in DevTools. A bundle that hides its React instance can also cause this.
- The tree is empty or stale. Check that the page finished loading and that you are not looking at a different tab's DevTools.
Confirming it works
Open the Counter page and select the Components tab. You should see a Counter entry in the tree. Click it and the right-hand side shows its State hook with the value 0. Click the button on the page and watch the value change to 1. Seeing that live update confirms the extension is attached and reading your app.
Exercise
You installed React Developer Tools while your app was already open in a browser tab. DevTools shows no Components or Profiler tab, and the toolbar icon is grey. What is the first thing to try, and why?
Show answer
Reload the page, then reopen DevTools. The extension attaches to React when the page loads, so a tab opened before installation is not detected until it reloads. If that fails, check for an iframe, a file:// URL without file access enabled, or a private window with the extension disabled.