React Performance Optimization
Track #2 of the study plan. React-specific performance optimization techniques.
Re-render model (the foundation)
- A component re-renders when: state changes, props change (by reference), or the parent re-renders.
- Re-render â DOM re-paint. The cost is in large trees/lists.
- Referential identity matters: new objects/arrays/functions on every render break memoization of children.
Memoization tools (and when NOT to use them)
React.memoâ skips a childâs re-render if its (shallow) props didnât change.useMemoâ memoizes expensive values / references passed to memoized children.useCallbackâ memoizes functions passed as props.- â ïž Donât memoize everything: it has cost and complexity. Measure first. The React Compiler (React 19) automates much of this.
Lists and rendering
- Stable
key(never the index in mutable lists). - Virtualization for long lists:
react-window,react-virtuoso, TanStack Virtual. - Code-splitting / lazy to defer JS â see react-code-splitting.
Concurrency (React 18+)
useTransitionâ marks updates as non-urgent (keeps the UI responsive).useDeferredValueâ defers an expensive derived value (e.g. a list filter).Suspenseâ declarative loading states and SSR streaming.
Context and state
- Split contexts by change frequency; memoize the
value. - Selectors (
use-context-selector, Zustand/Redux with selectors) to subscribe to only the needed slice.
Measurement (always before optimizing)
- React DevTools Profiler â flamegraph, âwhy did this renderâ.
<Profiler>API,performance.mark, Web Vitals (LCP, INP, CLS).- Lighthouse and bundle analyzer for the loading side.
Interview questions (practice)
- What causes a re-render? How do you diagnose excessive re-renders?
useMemovsuseCallbackvsmemo?- How would you optimize a list of 10k items?
- What are
useTransition/useDeferredValuefor?
Related: advanced-react · react-code-splitting · study plan.