Full answer
Start by defining what slow means. Is it input lag (INP), a slow first load (LCP), or a janky scroll? The tool and the fix depend on the answer.
For render problems, open React DevTools, record a Profiler session while performing the slow action, and read the flame graph. It shows which components rendered, how long each took, and, with "record why each component rendered" enabled, whether a prop, state or context change was the cause. In code, the <Profiler id onRender> component reports the same data programmatically. React 19.2 also adds Performance Tracks to the browser's performance timeline. Use the browser Performance panel to see long tasks, layout and paint cost outside React.
Common causes and fixes, from cheapest:
- State is too high. A keystroke in a form re-renders the whole page. Move the state into a smaller component, or pass expensive parts as children so they keep the same element.
- Unstable props defeat memo. Stabilize them or enable the React Compiler.
- Expensive work in render. Cache it with useMemo, or move it to a worker or the server.
- Huge lists. Virtualize them so only visible rows exist in the DOM.
- Urgent and non-urgent updates mixed. Use transitions or useDeferredValue.
- Context that changes often. Split it or switch to a store with selectors.
- Loading cost. Split code with lazy, remove unused libraries, and fetch in parallel with route loaders or Server Components.
After each change, measure again to confirm. Production builds behave differently from development, which has extra checks, so confirm in a production build with profiling enabled.
The example wraps a component in the Profiler, which reports each commit. Durations are not printed because they differ between runs.
import { Profiler, useState } from 'react';
function onRender(id, phase) {
console.log('profiler ' + id + ': ' + phase);
}
function Cart({ items }) {
return (
<ul>
{items.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
);
}
export default function App() {
const [items, setItems] = useState(['Notebook']);
return (
<div>
<button onClick={() => setItems((list) => [...list, 'Pen'])}>Add item</button>
<Profiler id="cart" onRender={onRender}>
<Cart items={items} />
</Profiler>
</div>
);
}Profiler calls onRender whenever a component inside it commits. In the first commit the phase is mount, after adding an item it is update. Output of the run in a development build: profiler cart: mount profiler cart: update
Key points
- Define the symptom first and measure with the React Profiler and the browser Performance panel.
- Enable "record why each component rendered" to find the trigger.
- Fix structure first (state placement, composition), then memoization, then lists, then scheduling.
- Verify in a production build and measure again after each change.
- Loading performance (bundle size, waterfalls) is a separate problem from render performance.
Common mistakes
- Adding memo and useMemo everywhere before measuring.
- Profiling a development build and treating its timings as production numbers.
- Fixing re-render counts that do not affect what users feel.
- Ignoring network and bundle size when the problem is the first load.
- Reading a flame graph without enabling the "why did this render" option.
Follow-ups
- What would you do about a keystroke in a form that re-renders a table of 5000 rows?
- How do Core Web Vitals such as INP relate to React rendering?
- How do you decide between memoization and restructuring components?
Tips
- Start the answer with the word "measure" and name the tool. It shows process.
- Give the fixes in a clear priority order.
- Mention production builds. Many candidates profile the slower development build.