React Foundations · Performance

The React Compiler

The React Compiler

For years, keeping a React app fast meant reaching for useMemo, useCallback, and memo by hand. It was easy to get wrong, and easy to forget. The React Compiler takes that job away: it is a build-time tool that automatically memoises your components and hooks. You keep writing plain code, and the compiler inserts the caching for you:

function List({ items }) {
  // The compiler memoises this derived value for you.
  const visible = items.filter((item) => item.visible);
  return <ItemList items={visible} />;
}

It works by checking each component against the Rules of React — pure render, no mutation of props or state, hooks called unconditionally. When your code follows the rules, the compiler can safely hoist and cache computations. When it cannot prove the code is safe, it skips that component.

Because the compiler does the memoisation, the manual hooks change role. useMemo, useCallback, and memo are no longer the default performance tool; they become escape hatches for the rare cases where you need precise control — a value used as an effect dependency, for example, where identity must be stable for a reason the compiler cannot see.

The compiler also runs validation passes during the build. If a component breaks the Rules of React — mutating a prop, calling a hook conditionally — the compiler reports it. Those are the same bugs Strict Mode surfaces at runtime, caught earlier.

In short: follow the rules, write ordinary components, and get memoisation for free.

You are about to answer a short quiz on the React Compiler.

  1. The React Compiler automatically memoises components and hooks.
  2. With the React Compiler, you must still wrap every derived value in useMemo.
  3. Under the compiler, useMemo and useCallback become ___ for precise control.
  4. The compiler runs validation passes that can report Rules-of-React violations.
  5. The compiler can memoise a value computed after an early ___.