React

React Compiler: what changes in your code

React Compiler adds memoisation at build time: the code drops useMemo and useCallback, but must obey the rules of hooks.

Key points

  • The compiler reads your code and inserts the memoisation you used to write by hand.
  • It works only on components that obey the rules of hooks: violations become silent bailouts.
  • It does not fix misplaced state: that stays a structural problem.

React Compiler does not change what you write: it reads components at build time and inserts the memoisation you used to add by hand with useMemo and useCallback.

What leaves the code

Manual memoisation was a defence: without it, every render rebuilt arrays, objects and callbacks, and memoised children re-rendered anyway. The compiler does the same work with one extra condition, that the component is pure enough to analyse.

// prima: memoizzazione scritta a mano
const rows = useMemo(() => sortRows(data), [data]);

// dopo: il compilatore inserisce la stessa memoizzazione
const rows = sortRows(data);

What it needs to work

  • Rules of hooks: no conditional hooks and none inside loops, or the component is skipped.
  • Pure components: mutating a prop or an outer variable during render blocks the optimisation.
  • Lint on: eslint-plugin-react-hooks reports the violations the compiler treats as bailouts.

Installation

npm i -D babel-plugin-react-compiler
npx react-compiler-healthcheck

The plugin ships under the MIT licence. react-compiler-healthcheck scans the project and prints how many components compile: that is the number to read before deleting manual memoisation.

What does not change

The compiler does not reduce the number of renders, it only avoids wasted work inside a render. When a component re-renders because state sits in the wrong place, the cost stays: move the state there, do not add a library.

Live records in the catalogue

Three components with lists and tables, where memoisation shows: lumina-interactive-list, interactive-logs-table and ruixen-contributors-table. To browse by category start from 111,985 components.

The limitation

Bailouts are silent: a skipped component compiles without errors and without gain, and the only signal is the healthcheck count. The optimised code is also harder to read while debugging, because the computed dependencies never appear in the source.

Where to continue

What version 19 changed is in React 19; the key mistakes that break memoisation are in key warnings in lists; the measured library comparison is in React libraries 2026.

Frequently asked questions

Should I remove every useMemo?

Only after the healthcheck and with the compiler on. When a component is skipped, manual memoisation is still needed.

Does the compiler work with Next.js?

Yes, through the Babel plugin or the bundler configuration. Keep the Next version and the plugin version aligned.

Does it reduce the number of renders?

No. It avoids wasted work inside a render and props that change identity every pass; render count depends on state.

What happens to a component that breaks the rules?

It is skipped without an error. The code behaves as it did before you turned the compiler on, but without the optimisation.

Is React Compiler open source?

Yes, it ships under the MIT licence together with the Babel plugin and the analysis tools.