
Performance questions separate candidates who have memorised hooks from those who have debugged a slow screen. Interviewers want a method: measure, find the cause, apply the smallest fix, measure again. These 16 questions follow that order.
How rendering works
1. What causes a component to re-render?
Four things: its state changes, its parent re-renders, a context it reads changes, or a hook it uses triggers an update. A changed prop doesn’t cause a render by itself; the parent re-rendering does, and React.memo uses props to decide whether to skip. More in rendering and re-renders.
2. Is a re-render the same as a DOM update?
No. Rendering means React calls your component and compares the result with the previous one. The DOM only changes where the output differs. Many re-renders are cheap. Optimise the ones that are slow or very frequent.
3. How do you find what’s slow?
- React DevTools Profiler: record an interaction, look at which components rendered, how long each took, and why.
- Browser Performance panel: long tasks, layout and paint cost.
- Field data: Core Web Vitals, especially INP, from real users.
Say this first in any performance answer. Guessing is the most common mistake. See debugging INP in React.
Reducing render work
4. What does React.memo do, and when does it fail?
It skips re-rendering a component when its props are shallowly equal to last time. It fails when a prop gets a new reference every render:
// memo is defeated: new object and new function each time
<Chart options={{ color: 'blue' }} onHover={(p) => setPoint(p)} />
// fixed
const options = useMemo(() => ({ color: 'blue' }), []);
const onHover = useCallback((p) => setPoint(p), []);
<Chart options={options} onHover={onHover} />
5. useMemo vs useCallback?
useMemo caches a computed value; useCallback caches a function. Both exist to keep references stable or to skip expensive work. Neither is free, so use them where a profile shows a benefit. See useCallback.
6. How can you reduce re-renders without memoization?
Change the structure. This is the answer senior interviewers hope for.
- Move state down. Keep state in the smallest component that needs it.
// Before: typing re-renders ExpensiveTable
function Page() {
const [query, setQuery] = useState('');
return (
<>
<input value={query} onChange={(e) => setQuery(e.target.value)} />
<ExpensiveTable />
</>
);
}
// After: the state lives in SearchBox, so the table isn't touched
function Page() {
return (
<>
<SearchBox />
<ExpensiveTable />
</>
);
}
- Pass children as props. Elements created by a parent that didn’t re-render are reused as-is.
7. Why do keys matter for performance?
Keys tell React which item is which between renders. With stable keys, React moves existing DOM nodes. With index keys, inserting at the top makes every row look changed, so each one updates, and component state can attach to the wrong row.
8. How do you stop context from re-rendering everything?
Every consumer re-renders when the context value changes. Split one large context into several, memoize the provider’s value, keep fast-changing values out of context, or use a store with selectors. Details in avoiding context re-renders.
Large lists and heavy work
9. How do you render 10,000 rows?
Virtualize: render only the rows in view plus a small buffer, inside a container sized for the full list. Discuss variable row heights, keyboard and screen-reader support, and whether pagination would serve users better. See list virtualization.
10. What do useTransition and useDeferredValue do?
They mark an update as non-urgent so urgent ones (typing, clicking) aren’t blocked.
function Search({ items }) {
const [query, setQuery] = useState('');
const deferredQuery = useDeferredValue(query);
const isStale = query !== deferredQuery;
return (
<>
<input value={query} onChange={(e) => setQuery(e.target.value)} />
<div style={{ opacity: isStale ? 0.6 : 1 }}>
<Results items={items} query={deferredQuery} />
</div>
</>
);
}
The input updates immediately; the heavy list renders when the browser has time. Results should be wrapped in memo so it only re-renders when the deferred value changes.
11. Debounce or transition?
Debounce delays the work by a fixed time, which is right for network requests. A transition starts immediately and can be interrupted, which is right for expensive rendering.
12. Where should an expensive calculation go?
In useMemo if it depends on props or state. In a Web Worker if it blocks the main thread for long. On the server if it doesn’t need to run in the browser at all.
Loading performance
13. How do you reduce bundle size?
Split by route with lazy and Suspense. Load heavy, rarely used features on demand. Audit dependencies with a bundle analyser. Import only what you use. Set a size budget in CI. See code splitting and lazy loading.
14. How does server rendering help, and what can go wrong?
HTML arrives sooner, which improves LCP. The risks are slow hydration on large pages and hydration mismatches. Streaming with Suspense boundaries, and keeping interactive islands small, address both.
15. How would you improve image-heavy pages?
Correct sizes with srcset, modern formats, loading="lazy" below the fold, explicit width and height to prevent layout shift, and priority loading for the LCP image.
Judgement
16. When is optimisation a mistake?
When there’s no measured problem. Wrapping everything in memo and useCallback adds code, hides bugs behind stale closures, and often changes nothing. The React Compiler now applies much of this memoization automatically in projects that use it, which is another reason to fix structure first and reach for manual memoization last.
A model answer structure
For “this page is slow, what do you do?”:
- Reproduce and measure (Profiler, Performance panel, field data).
- Classify: too many renders, slow renders, too much JavaScript, or network.
- Apply the smallest fix: move state, split context, virtualize, split code.
- Measure again and add a guard (budget, test, alert) so it doesn’t return.
More practice: React interview questions and Core Web Vitals.
