Lesson 78 of 80
Reading a flamegraph tells you the shape of a render. The Profiler is the workflow that gets you a flamegraph worth reading in the first place — record, measure, and prove a fix actually helped.
14 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
This topic is about judgment and practical tradeoffs more than a single right answer — a mock interview is the better way to test yourself on it.
Be interviewed on this →Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Knowing how to read a flamegraph's shape is one skill. Actually producing a useful recording — capturing the right interaction, isolating the right commit, and pulling real numbers out of it instead of an eyeballed guess — is a different, earlier skill, and it's what this lesson covers.
The React DevTools Profiler tab records every commit that happens while it's recording: each state update, each re-render, with a duration attached. You press record, do the exact user interaction you're investigating, stop, and then you have a timeline of every commit that interaction caused — which is the raw material a flamegraph is built from.
The Profiler API lets you do the same measurement in code, which is useful for logging or automated checks:
import { Profiler } from "react";
function onRenderCallback(id, phase, actualDuration, baseDuration) {
console.log(`${id} (${phase}): actual ${actualDuration.toFixed(2)}ms, baseline ${baseDuration.toFixed(2)}ms`);
}
function App() {
return (
<Profiler id="Dashboard" onRenderCallback={onRenderCallback}>
<Dashboard />
</Profiler>
);
}
actualDuration is how long this commit actually took, including any memoization currently in place. baseDuration is React's estimate of how long the subtree would take to render without any memoization at all. The gap between them is what memoization is buying you — if you add memo somewhere and actualDuration drops while baseDuration stays roughly the same, that's a measured win, not a guess.
In the browser extension itself, the same workflow: hit record, perform the interaction, stop, then turn on "Record why each component rendered" in the Profiler's settings gear. That single setting is the highest-value one in the whole tab — it annotates every bar with the actual reason, like "props changed: value" or "hooks changed," turning "something re-rendered" into "this specific prop caused it."
This is the workflow that turns this track's memoization lesson from theory into evidence — instead of assuming memo or useMemo helped, you record, check the "why did this render" reason, and confirm the duration actually dropped. Once you have a recording worth looking at, this track's lesson on reading a flamegraph's shape is what tells you how to interpret it.