Using the React DevTools Profiler
React DevTools Profiler
~13 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
So far we've made re-renders visible with a hand-built RenderCounter – useful, but coarse. The React DevTools Profiler is the official tool for the same question, with considerably more detail: WHAT rendered and for how long, WHY a particular component re-rendered, and how time is distributed across the whole tree.
Installation
Install the "React Developer Tools" browser extension (Chrome, Firefox, or Edge – each available in the official add-on store). Then open the browser DevTools (F12) in our running app – two new tabs appear: "⚛️ Components" and "⚛️ Profiler".
Achtung: The Profiler tab only works in the DEVELOPMENT build (npm run dev), not in the production build (npm run build) – React deliberately strips the extra information needed for it out of the production bundle to keep it smaller and faster.
Your first recording
- Open the "⚛️ Profiler" tab
- Click the blue record circle (⏺) – it turns red, recording is running
- Do something in the app that triggers a re-render (e.g. click "Add to Cart")
- Stop the recording with the same button
After stopping, a "flame chart" appears: each row is one render pass (a "commit"), each bar in it a component. WIDER bars mean LONGER render time, GRAY bars mean "did NOT re-render" (React still shows them for orientation, but grayed out).
"Why did this component render?"
Click on any single, colored bar – a side panel shows details, often including "Why did this render?" with a list of the CHANGED props/state values that caused the render. This is the direct, tool-assisted replacement for our manual RenderCounter experiment from chapter 27 – enable the "Record why each component rendered while profiling" option in the profiler settings (gear icon) for this.
Hands-on experiment: watching CartWidget in the profiler
Start a new recording, click "Add to Cart" twice on the SAME product, stop the recording. You should see: ProductCard itself does NOT re-render (its isFavorite state doesn't change), but CartWidget AND ProductListPage each re-render. Click the CartWidget bar and read the "Why did this render" explanation – it should list the changed useSelector return value (the item count) as the cause.
Using "Ranked" mode
At the top of the profiler panel there's a toggle between "Flamegraph" and "Ranked". Ranked mode sorts ALL components of a commit by render time, descending – ideal for QUICKLY finding the "most expensive" components of a given update in a large app, without having to scan the whole tree.
Tracking interactions live instead of recording manually
An alternative to manual start/stop: the small circle button next to the record button enables "Reload and start profiling" – useful for profiling the VERY FIRST render of the app (right after loading), which manually starting after the page has loaded always misses.
Tipp: Rule of thumb for using the profiler: DON'T pre-emptively optimize every component ("premature optimization") – first PROFILE to find actual, measurable bottlenecks, THEN fix them with the tools from the coming chapters (React.memo, virtualization, concurrent features). A bar that's 0.3ms wide needs no optimization, no matter how inelegant the code behind it looks.
Achtung: Remember <StrictMode> in main.jsx: in development, React DELIBERATELY renders some components twice to surface side-effect bugs (see "React for Beginners" chapter 2). The profiler shows these duplicate renders too – don't mistake that for a real performance problem. In the production build (npm run build), this double rendering doesn't happen.