The React Compiler is a build-time optimizer (a Babel plugin, also available for SWC-based setups and integrated into frameworks such as Next.js and Expo) that analyzes components and hooks and automatically memoizes values, callbacks and JSX. In effect it inserts fine-grained useMemo/useCallback/memo for you, often more precisely than you would by hand, even after early returns where manual hooks aren't allowed. v1.0 was released as stable in October 2025 and works with React 17, 18 and 19 (older versions need react-compiler-runtime). It relies on your code following the Rules of React (pure render, immutable props and state, rules of hooks). Code that breaks them is skipped, not miscompiled, and the ESLint plugin reports why.
function ProductList({ products, filter, onSelect }) {
const visible = products.filter(p => p.category === filter);
return (
<ul>
{visible.map(p => (
<Row key={p.id} product={p} onClick={() => onSelect(p.id)} />
))}
</ul>
);
}
Without the compiler, any parent re-render re-runs the filter and recreates every onClick, so memoized rows still re-render. The compiler rewrites the component to cache visible (keyed on products and filter) and the rendered JSX, so unrelated parent re-renders reuse the previous output. Conceptually it's like memoizing every reactive scope automatically, using an internal cache array (useMemoCache).
useMemo/useCallback/memo in the common case. Existing ones can stay. The compiler works alongside them, but removing them carelessly can change effect dependency behaviour, so do it gradually and with tests.'use no memo' directive opts a component or file out, and compilationMode: 'annotation' with 'use memo' lets you opt in incrementally.// babel.config.js
module.exports = {
plugins: [['babel-plugin-react-compiler', { target: '19' }]], // the plugin should run first
};
eslint-plugin-react-hooks from v6 onward as recommended rules) to find violations.reactCompiler: true), Expo and React Router have documented integrations.useMemo/useCallback/memo: mostly unnecessary in new code, removed carefully in old code.Spotted a mistake or a rights concern? Report an issue