ReactPerformanceFrontend

React 19 Compiler: Goodbye useMemo, Hello Optimization-by-Default

April 25, 2026 6 min read 77 views
React 19 Compiler: Goodbye useMemo, Hello Optimization-by-Default

#React 19 Compiler — Optimization by Default

For a decade React devs sprinkled useMemo, useCallback, and React.memo like seasoning. The React Compiler ends that ritual.

#What it does

The compiler runs at build time, traces your component's data flow, and emits the equivalent of useMemo for every value it determines is "stable". You write idiomatic React; you get hand-tuned performance.

tsx
1// Before: manual
2const filtered = useMemo(() => items.filter(i => i.active), [items]);
3
4// After: just write it
5const filtered = items.filter(i => i.active);
6// Compiler memoizes this automatically

#Where it falls short

  • External state (refs, mutable objects) confuses static analysis.

  • Non-pure render logic breaks assumptions — keep components pure.

  • Bundle size grows slightly (~3-5%) from the inserted cache code.
  • #When NOT to rely on it

  • Tight render loops in canvas/WebGL — use refs + manual rAF.

  • Heavy expressions that depend on third-party libs — measure first.
  • The compiler is "aspirin for re-renders," not a replacement for thinking about data flow.

    Share: