Welcome to HowToShipIt — practical how-to guides for developers: code, AI tools, and servers, explained step by step.

How to Use the React Profiler to Fix a Slow App (2026)

Your React app feels slow, so you reach for useMemo. Then you wrap things in memo. Then you sprinkle useCallback everywhere. The app is no faster, the code is harder to read, and you still do not know which component is actually slow. That is the exact problem the React Profiler solves: it replaces guessing with a recording of what rendered, how long it took, and why.

This guide shows you how to use the React Profiler properly — the Profiler tab in React DevTools, how to read the flame chart and the ranked chart, the five slow-render patterns it keeps exposing, and the fixes that actually move the numbers. It is written for React 19 in 2026, but the workflow works on any recent version. Last verified 26 October 2026.

What the React Profiler actually measures

There are two Profilers, and people confuse them constantly. The first is the Profiler tab in React DevTools, the browser extension. You press record, interact with your app, press stop, and you get a visual timeline of every commit — every time React applied updates to the DOM — while you were recording.

The second is the <Profiler> component from React itself. You wrap a tree in it and React calls your onRender callback every time that tree commits, with timings you can log, aggregate, or send to your analytics. The DevTools tab is for interactive debugging; the component is for programmatic measurement. This post starts with the tab, because that is where you will find the bottleneck, and covers the component later for when you want numbers over time.

One important caveat up front, straight from React’s own docs: profiling adds overhead, so it is disabled in the production build by default. Profile in development to find the problem, then verify the fix in a production build before you declare victory — development timings are inflated and are only useful for comparison, not as absolute numbers.

Record a session that actually tells you something

Most Profiler sessions are useless because they record the wrong thing: the developer opens the app, clicks around randomly, and stares at a wall of commits. Record one interaction at a time, the way a user would do it.

First, install the React Developer Tools extension for Chrome or Firefox and open your app in development mode. Switch to the Profiler tab. Before you record, open DevTools settings (the gear icon) and enable “Record why each component rendered while profiling”. Without this setting, the Profiler tells you what rendered but not why — and the why is the whole point.

Then follow this sequence:

  1. Let the page settle completely, so the initial mount is not mixed into your recording.
  2. Press record.
  3. Do exactly one thing: type one character in the search box, toggle one filter, click one tab.
  4. Press stop.

You will see one bar per commit along the top. Click the longest bar — the slowest commit — and the flame chart below updates to show the components in that commit. That single commit is your investigation. If you recorded five interactions, you have five investigations tangled together; record one, fix one, repeat.

How to read the flame chart and the ranked chart

The flame chart shows the component tree for the selected commit, root at the top, children below it. Each bar is sized by how long that component took to render, including its children — so a long bar at the top may just mean it has an expensive child, and the real culprit is the long bar nested underneath it. Follow the longest bars downwards until you find the component whose own render time is large.

Switch to the ranked chart when you want the short answer. It sorts every rendered component by render duration, slowest first, regardless of where it sits in the tree. It is the fastest way to spot the worst offender in a busy commit. Use the flame chart to understand the cascade; use the ranked chart to prioritise.

Now click a component in the flame chart. The sidebar shows why it rendered. The reasons you will see, in plain English, are: it rendered for the first time; its props changed; its state changed; its hooks changed; its context changed; or its parent rendered. That last one is the most common and the most misunderstood — it means the component re-rendered not because anything about it changed, but because its parent did, and React re-rendered the whole subtree by default. That single line tells you whether you have a parent-cascade problem, a prop-stability problem, or a state-placement problem, and each has a different fix.

Pattern 1: The parent cascade

This is the number-one finding in slow React apps. A piece of state lives too high in the tree — a search input at the top of a dashboard, say — and every keystroke re-renders everything below it: the sidebar, the charts, the tables, all of it. The Profiler shows this as “the parent component rendered” on dozens of components that did nothing wrong.

The fix is not memoisation. The fix is moving the state down. If only the search box and the results list care about the query, the query state should live in the component that owns both of them, not in the app root. And if a heavy child genuinely does not depend on the changing state, you can stop the cascade by extracting it: a component only re-renders when its parent does if it is actually rendered by that parent in the same render pass. Passing a heavy subtree in as children from a stable parent is the classic escape hatch — the parent re-renders, but the children element it received is the same reference, so React skips it.

function Dashboard() {
  const [query, setQuery] = useState('');
  // Every keystroke re-renders everything Dashboard renders.
  return (
    <>
      <SearchBox value={query} onChange={setQuery} />
      <ExpensiveCharts />
      <OrdersTable />
    </>
  );
}

Move the query state into a smaller component that only renders the search box and the results, and the charts and tables stop re-rendering on every keystroke. Profile before and after: the commit should shrink from dozens of components to two or three.

Pattern 2: Unstable props that defeat memo

You wrapped a component in memo, the Profiler still shows it re-rendering, and the reason is “props changed” — even though the values look identical. This is the reference-equality trap. memo does a shallow comparison: it checks whether each prop is the same value as last time. A new object literal, a new array, or a new inline function is a different reference every render, even if its contents are identical.

// Bad: a fresh object and a fresh function on every parent render.
<Chart data={data} config={{ theme: 'dark' }} onSelect={(id) => select(id)} />

// Good: stable references, so memo can actually do its job.
const config = useMemo(() => ({ theme: 'dark' }), []);
const handleSelect = useCallback((id) => select(id), [select]);
<Chart data={data} config={config} onSelect={handleSelect} />

This is the pattern the Profiler’s “why did this render” panel was made for: when it says “props changed” and names a prop whose value looks the same, check whether that prop is created inline. The fix is upstream, in the parent that creates the prop — not in the child that receives it. memo without stable props is decoration.

Pattern 3: Context that fans out to everyone

Context is the quietest performance killer in React. When a context value changes, every component that consumes that context re-renders — and, crucially, so does everything rendered inside those consumers in the same pass. The classic mistake is one context carrying unrelated values:

// Bad: changing the theme re-renders every user-data consumer too.
<AppContext.Provider value={{ user, theme, settings }}>

Split unrelated values into separate contexts — a user context, a theme context, a settings context — so a change in one only wakes its own consumers. And keep the value itself stable: an object literal in the provider’s value prop is a new reference on every provider render, which re-renders every consumer even if nothing inside it changed. Memoise the value with useMemo, keyed on the values it actually contains. If the Profiler shows a whole subtree lighting up on an unrelated change and the reason is “context changed”, you have found this pattern.

Pattern 4: Expensive work done on every render

Sometimes the component genuinely is slow: it filters ten thousand rows, formats dates, or builds a chart dataset on every render, including renders triggered by unrelated state. The ranked chart shows it at the top with a large render time, and the reason is honest — its own state or props did change. The fix is useMemo, but only for work that is actually expensive. Memoising a cheap string concatenation adds overhead and complexity for nothing; the Profiler is how you tell the difference. If a computation takes a fraction of a millisecond, leave it alone. If it dominates the commit, memoise it keyed on its real inputs:

const visibleRows = useMemo(
  () => rows.filter((row) => row.category === category),
  [rows, category]
);

Two traps here. First, a dependency array that omits a real input gives you stale data — the memoised value does not update when it should. Second, a dependency that is itself a new reference every render (an inline array, an unmemoised object) defeats the memo entirely. The Profiler catches the second trap: if the memoised component still re-renders, check the stability of its inputs first.

Pattern 5: Long lists without keys or virtualisation

A list of a few hundred rows that re-renders on every keystroke is a different problem from a slow component: the work is not one expensive render, it is hundreds of cheap ones. Two fixes, in order. First, stable keys: never use array indexes as keys for a list that changes order, filters, or grows, because React then cannot match old items to new ones and re-renders more than it needs to. Use a stable id from your data. Second, for genuinely long lists, virtualisation: render only the rows on screen with a library like react-window or TanStack Virtual, instead of thousands of DOM nodes. The Profiler makes the case for you — a ranked chart full of identical row components is the signature of this pattern.

Measuring with the <Profiler> component

The DevTools tab is interactive, but sometimes you need numbers over time: a dashboard that degrades after an hour, a regression you want to catch in staging, or a before-and-after measurement you can quote. That is what the <Profiler> component is for. Wrap the tree you care about and React calls your callback on every commit:

import { Profiler } from 'react';

function onRender(id, phase, actualDuration, baseDuration, startTime, commitTime) {
  // phase is "mount", "update", or "nested-update".
  // actualDuration: time this commit actually took.
  // baseDuration: estimated time without any memoisation.
  console.log(`${id} (${phase}): ${actualDuration.toFixed(1)}ms`);
}

function App() {
  return (
    <Profiler id="Dashboard" onRender={onRender}>
      <Dashboard />
    </Profiler>
  );
}

The two numbers that matter are actualDuration and baseDuration. baseDuration estimates what the subtree would cost with no memoisation at all; actualDuration is what it actually cost. If your memoisation is working, actualDuration should drop well below baseDuration after the initial mount. If the two stay close together, your memo and useMemo calls are not biting — go back to the unstable-props pattern above. You can nest multiple <Profiler> components to measure different parts of the app separately, but keep them sparse: each one adds CPU and memory overhead, and React’s docs say to use them only when necessary.

Remember the production caveat: <Profiler> is disabled in the standard production build. If you want production measurements, you need a special profiling build of your app — do not ship the DevTools-style instrumentation to all users and call it monitoring. A common setup is to enable the profiling build only in staging, or behind an internal flag, and to sample rather than log every commit.

When not to memoise (and what React Compiler changes)

The Profiler has a second job: telling you when to stop. If the ranked chart shows a component at 0.2ms, wrapping it in memo will not make your app faster — the comparison itself costs about as much as the render. Memoisation pays off on expensive components and on components that re-render constantly with unchanged props. Everywhere else it is code you have to maintain for no return.

There is also a bigger shift under way. If your app uses the React Compiler — the build-time tool that automatically memoises components, which we covered in our React Compiler enable guide — much of the manual memo / useMemo / useCallback work in this post becomes unnecessary for new code. The Profiler does not become unnecessary, though: it is still how you find out which component is slow in the first place, and how you verify the compiler actually fixed it. Measure first, whether a human or a compiler writes the memoisation. And if you are on an older codebase without the compiler, the manual patterns above are still the correct tools.

Your 20-minute React Profiler workflow

  1. Pick the slowest interaction your users actually complain about — not the one that is easiest to reproduce.
  2. Record that one interaction, alone, with “Record why each component rendered” enabled.
  3. Open the slowest commit, switch to the ranked chart, and name the top three components.
  4. For each one, read its “why did this render” reason and match it to a pattern above: parent cascade, unstable props, context fan-out, expensive compute, or long list.
  5. Apply one fix. Re-record the same interaction and compare the commit: fewer components, lower total time, or it did not work and you try the next pattern.
  6. Only then move on to the next interaction. One bottleneck at a time is how slow apps actually get fast.

The temptation with React performance work is to optimise everything at once and hope. The Profiler exists so you do not have to. Record, read the reason, fix the one pattern, and measure again. Do that five times and your app will feel like a different app — and you will be able to say exactly why.

Further Reading & References

Leave a Comment