For ten years, React devs sprinkled useMemo and useCallback to avoid re-renders. The React Compiler reads your code at build time and inserts those memoizations automatically. The whole 'wrap everything just in case' era is ending.
What it does
The React Compiler is a Babel plugin (and Vite/Next plugin wrapping it) that analyzes your JSX and detects values that would benefit from memoization. It then inserts the equivalent of useMemo / useCallback at build time. The runtime output behaves as if you'd manually wrapped every relevant value — but you didn't.
What it doesn't do
- It doesn't change semantics. Your component still works the same; it just renders fewer times.
- It doesn't replace useState / useEffect / useContext. Those are about state and side effects, not memoization.
- It doesn't optimize away genuinely expensive computations. If your render does
filterMassiveDataset(query), the Compiler memoizes the dataset reference but the filter still runs when the query changes. (Pair with useTransition or useDeferredValue for the perceived-speed win.)
How to enable
Add the babel-plugin-react-compiler to your build config. For Vite: install babel-plugin-react-compiler, add it to @vitejs/plugin-react's babel.plugins option. Restart dev server. Done.
The opt-in escape
If a specific component's behavior depends on identity-sensitive re-renders that the compiler shouldn't change, add the directive 'use no memo' as the first statement in the component. The Compiler skips it.