All posts

Letting the React Compiler memoize for you

Oct 14, 2026 · Linus

reactperformance

The React Compiler analyzes components at build time and inserts fine-grained memoization automatically.

Before and after

// Before: manual memoization
const label = useMemo(() => `Clicked ${count} times`, [count])
const onClick = useCallback(() => setCount((c) => c + 1), [])

// After: plain code, memoized by the compiler
const label = `Clicked ${count} times`
const onClick = () => setCount((c) => c + 1)

Your source stays the same; only the compiled output changes. You can spot it in the bundle by the react.memo_cache_sentinel symbol.

Keep components pure and follow the Rules of React, and the compiler does the rest.