The React Compiler

Automatic memoization: how it works and whether to ship it.

Builds on Memoization.

Chapter 29 ended with a working fix: useMemo for the sorted array, useCallback for the handler, a constant moved out of the component, all so that one memo would hold. It worked, and it was fragile. Add one inline prop next month and the whole thing silently stops working. Get a dependency array wrong and you've traded a slow render for a stale-value bug.

The React Compiler does that work for you, at build time, more precisely than you would by hand. This chapter covers what it does, how it does it (with the real compiler running on this page), the rules your code has to follow for it to be safe, what happens when code breaks them, how to set it up and configure it, how to adopt it in an existing codebase, and whether you should ship it. Short answer to the last one: yes, with your eyes open.

The problem: manual memoization doesn't scale#

Here's a pattern close to the one react.dev uses to introduce the compiler. It's carefully memoized, and it still doesn't work:

const Item = memo(function Item({ todo, onClick }) {
  /* renders one expensive row */
});

function TodoList({ todos, filter }) {
  const visible = useMemo(() => filterTodos(todos, filter), [todos, filter]);
  const handleClick = useCallback((todo) => {
    /* ... */
  }, []);
  return (
    <ul>
      {visible.map((todo) => (
        <Item key={todo.id} todo={todo} onClick={() => handleClick(todo)} />
      ))}
    </ul>
  );
}

handleClick is stable, but () => handleClick(todo) is a new arrow on every render, so every memoized Item gets a new onClick and re-renders anyway. Nobody notices, because nothing breaks; it's just slower than it looks.

That's the general shape of the problem. Manual memoization:

  • fails silently, as soon as any prop loses its identity;
  • is all or nothing per value: you memoize what you remembered to, and the rule "every object passed to a memoized child must be stable" has to hold everywhere, forever;
  • can't go everywhere: hooks can't be called conditionally, so you can't useMemo something computed after an early return;
  • adds code with dependency arrays, which can be wrong in both directions.

A compiler doesn't forget, and it can read the data flow of your whole component.

What the compiler produces#

The React Compiler is a Babel plugin (babel-plugin-react-compiler) that rewrites your components and hooks at build time. The editor below runs the real compiler, version 1.0, in your browser. The left side is ordinary code with no memoization. The right side is what your bundler would actually ship.

A simple component, compiled
babel-plugin-react-compiler 1.0
App.tsx (your code)
compiled output
Runs exactly the code on the right, with react/compiler-runtime.

Read the compiled Greeting from the top. Every piece maps to something you already know.

  • import { c as _c } from "react/compiler-runtime" and const $ = _c(3). _c is a hook (internally it calls useMemoCache). It returns this component instance's memo cache, an array with 3 slots that React stores on the component's fiber, right next to its hook state. The compiler counted at build time how many slots this component needs.
  • if ($[0] === Symbol.for("react.memo_cache_sentinel")). On the first render every slot holds a sentinel, a unique symbol that means "never written". <Logo /> depends on nothing reactive, so the compiler only needs to know whether it was ever created. It's created once and reused forever.
  • if ($[1] !== message). The header depends on message. Slot 1 stores the message it was last built with, slot 2 stores the element. If message is the same (!== is the same check as Object.is here, apart from the NaN and ±0 corner cases), the old element comes back.
  • props became t0 and is destructured inside. That's how the compiler gets hold of each prop as a separate value to track.

Now look at the compiled App. The element <Greeting name={name} /> is cached on name. Press Run the compiled output, open the console, and click Re-render a few times. App re-renders, but because it returns the same <Greeting> element object, React's identical-props bailout (chapter 29) skips Greeting and Logo. Nothing logs. Click Toggle name: Greeting re-renders, but Logo still doesn't, because the <Logo /> element came out of slot 0 unchanged. That's what memo, useMemo and useCallback were trying to achieve by hand, and nobody wrote memo anywhere.

Here's the same mechanism one step at a time:

Compiled code and its cache slots
Compiled Greeting (simplified)const $ = _c(3);const message = `Hello, ${name}!`;if ($[0] === SENTINEL) {t1 = <Logo />; $[0] = t1;} else t1 = $[0];if ($[1] !== message) {t2 = <header>{t1}<h1>{message}</h1></header>;$[1] = message; $[2] = t2;} else t2 = $[2];return t2;Memo cache on the fiberprops: name = "Ada"$[0]SENTINEL$[1]SENTINEL$[2]SENTINELSENTINEL = Symbol.for("react.memo_cache_sentinel")
Step 1 of 5

First render. _c(3) asks React for this component's memo cache: an array of 3 slots stored on its fiber. On mount every slot holds a sentinel, a unique symbol that means "never written".

How it works#

You don't need compiler internals to use it, but interviewers like to ask, and the model explains every bailout you'll see later.

1. Lower the code into an intermediate representation#

The compiler is a Babel plugin, but it doesn't work on Babel's syntax tree for long. It lowers each component and hook into its own HIR, a High-level Intermediate Representation: a control-flow graph of simple instructions (t1 = <Logo />, t2 = message !== ...), with every branch, loop and early return explicit. The analysis runs on this IR rather than on Babel's tree; Babel is mostly how it plugs into your build.

2. Understand data flow and mutability#

On that graph, a series of passes works out, for every value, where it comes from and who can change it:

  • Reactive values are the ones that can differ between renders: props, state, context, the results of hooks, and anything computed from them. message is reactive because name is.
  • Non-reactive values can't change: module-level constants, literals, and functions React promises are stable, like a setState setter. That's why a handler like e => setQuery(e.target.value) gets a sentinel check (you'll see one in the next example): its only input never changes.
  • Mutation: the compiler tracks where each object is created and the last place it's modified. const list = []; list.push(a); list.push(b); is one unit of work, because the array isn't finished until the last push.

It also has built-in knowledge of React's APIs and common JavaScript ones, and it infers types (is this a hook? a primitive? a JSX element?) so it can reason about what each call might mutate.

3. Group the work into reactive scopes#

A reactive scope is a group of instructions that produce one or more values together, plus the reactive values they depend on. In Greeting, building the <header> element is one scope with one dependency, message. Scopes whose instructions interleave are merged, since they can't be cached separately without reordering your code. The compiler doesn't reorder your code.

4. Generate the cache code#

Each scope becomes an if block: "if any dependency differs from the cached copy, run the instructions and store the dependencies and outputs; otherwise load the outputs from the cache." The compiler numbers the slots, counts them, and emits the _c(n) call. Callbacks that capture nothing reactive are hoisted out to module-level functions like _temp, so they're created once.

Because this works on the control-flow graph, not on hook calls, the compiler can memoize code that runs after an early return or inside a branch, which useMemo can't do: hooks can't be called conditionally, but plain if blocks can do anything.

Where the cache lives, and why a discarded render can't corrupt itDeep dive

_c(n) calls React's internal useMemoCache(n). In React 19.3.1's react-dom source you can see it: the cache is stored as memoCache on the fiber's update queue. On mount it allocates an array of n slots and fills each with Symbol.for("react.memo_cache_sentinel"). On an update it copies the arrays from the current fiber (array.slice()) into the work-in-progress fiber. That copy matters for concurrent rendering (chapter 23): if React throws away an interrupted render, the slots it wrote were only in the work-in-progress copy, so the committed cache is untouched. In development it also warns if n changes between renders, the cache's version of the rules of hooks.

What it doesn't do#

Two limits from react.dev's own docs. It only compiles components and hooks, not arbitrary functions: a helper calculateTotal(items) isn't memoized by itself, though calling it inside a component memoizes that call's result as part of the component. And the cache is per component instance: if ten components run the same expensive calculation, it runs ten times. For that you'd still profile and cache outside React.

A list filter, compiled#

The reading list's search, written with no memoization at all:

A filtered list, compiled
babel-plugin-react-compiler 1.0
App.tsx (your code)
compiled output
Runs exactly the code on the right, with react/compiler-runtime.

Three things to find in the compiled BookList:

  1. The filter is memoized on books and query. The outer if ($[0] !== books || $[1] !== query) block contains books.filter(...) and visible.map(...). If neither changed, the filter doesn't run at all and the <li> list comes straight from the cache (the compiler stores the list it builds from visible, since that's what the JSX uses). That's the useMemo you would have written, with the correct dependencies.
  2. Scopes nest. Inside, the filter callback has its own scope on query, and the onChange handler has a sentinel check because it only uses setQuery. The final <div> has its own scope that depends on the two pieces inside it.
  3. The <li> callback became _temp. It captures nothing reactive, so it's hoisted to the module and created once.

Try an experiment in the editor. Add const [count, setCount] = useState(0); and a <button onClick={() => setCount(count + 1)}>{count}</button> above the input. Look at the outer scope: its condition now includes count, because the button is created between visible and its use, so their scopes interleave and get merged. The compiler's granularity follows your code's order. It's usually finer than hand-written memoization, but not always perfect, and that's fine: the cost of an extra recomputation in a merged scope is the same as no memoization at all.

The Rules of React it depends on#

The compiler only skips work. It's only correct to skip a computation if running it again would give the same result. So it assumes your code follows the Rules of React, which react.dev states as three groups:

  • Components and hooks must be pure. Same inputs, same output (idempotent). Side effects run in event handlers and effects, not during render. Don't call impure functions like Date.now() or Math.random() during render.
  • Props, state and hook values are immutable. Never mutate props or state; never mutate values returned from hooks or passed to hooks; don't mutate a value after it has been passed into JSX. Local objects you create in this render are fine to mutate.
  • The Rules of Hooks (chapter 8): call hooks only at the top level, only from components and other hooks; never call components as functions or pass hooks around as values.

The immutability rule is the one memoization leans on hardest. A cache check like $[0] !== books asks "is this the same array?" and assumes that if it is, its contents are the same too. If someone pushed into books in place, the array is the same object with different contents, and the cached list is stale. Manual useMemo has exactly the same problem; the compiler just applies memoization in far more places.

When code breaks the rules#

The compiler validates as it goes, and when it can prove something is wrong, it bails out: it leaves that component or hook exactly as you wrote it, uncompiled, and moves on. Your build doesn't fail, and the rest of the app is still optimized. Here's a component that reads a ref during render, which the Rules of React forbid:

A rule-breaking component
babel-plugin-react-compiler 1.0
App.tsx (your code)
compiled output
Runs exactly the code on the right, with react/compiler-runtime.

The diagnostics under the editor say Not compiled: Cannot access refs during render, with an explanation that refs aren't meant for rendering. (The compiler actually reports it once per offending access, three times here; this page shows each distinct message once.) Look at the output: RenderCounter is left untouched, no _c, no slots.

Now look at App. It was compiled, and it caches <RenderCounter label="Counter" /> with a sentinel check, because the element depends on nothing reactive. Run the compiled output and click the button. The counter text stays at "rendered 1 times", because RenderCounter never re-renders. Without the compiler it would climb with every click. So "the compiler skipped the broken component" doesn't mean "the broken component behaves as before". Its parent is compiled, and the parent's memoization changes when it renders. Code that depended on re-rendering for its side effects is exactly the code the rules said not to write.

What the compiler can't detect#

Some violations are invisible to static analysis. Here's an impure render:

An impure render compiles silently
babel-plugin-react-compiler 1.0
App.tsx (your code)
compiled output
Runs exactly the code on the right, with react/compiler-runtime.

No diagnostics. Run it and click Refresh: the time never changes. The compiler treats LastUpdated as pure, so its whole output is cached under a sentinel, and App caches the <LastUpdated /> element too. Before the compiler, each click re-rendered it and the time updated by accident.

This is why react.dev pairs the compiler with ESLint: eslint-plugin-react-hooks has a purity rule that flags known impure functions like Date.now() during render, and an immutability rule for mutating props and state. The fix here is to make the time real state (set it in the click handler) or to compute it in an effect. Treat any re-render your code depends on as a bug the compiler will eventually expose.

Other bailouts you'll meet#

  • "Existing memoization could not be preserved." If you already have useMemo(() => items.filter(... query ...), [items]) with a dependency missing, the compiler infers query as a dependency, sees it disagrees with yours, and skips the component rather than change when the value updates. The preserve-manual-memoization lint rule reports the same thing.
  • Incompatible libraries. Some APIs keep hidden mutable state behind a stable reference ("interior mutability"), so caching anything derived from them goes stale. react.dev names react-hook-form's watch and TanStack Table's useReactTable; the compiler skips components using known ones, and the incompatible-library lint rule flags them. MobX's observer is named as a problem the linter doesn't detect yet. For react-hook-form, useWatch is the compatible alternative.
  • Unsupported syntax, reported by the unsupported-syntax rule.

panicThreshold: skip, or fail the build#

What the compiler does with an error is configurable:

panicThresholdBehavior
'none' (default)Skip components that can't be compiled and keep building.
'critical_errors'Fail the build only on critical compiler errors.
'all_errors'Fail the build on any compiler diagnostic.

react.dev is direct about production: it "should always use 'none'". A stricter threshold is a development tool for finding every component that isn't being optimized, for example panicThreshold: isDevelopment ? 'critical_errors' : 'none'. To see skipped components without failing anything, use the logger option, which receives events such as CompileSuccess and CompileError per file. The editors on this page use exactly that: panicThreshold: 'none' plus a logger, and the "Not compiled" lines are the logged errors.

Setting it up#

The compiler is one package, babel-plugin-react-compiler, installed as a dev dependency. Because it changes memoization behavior, react.dev suggests pinning an exact version if your test coverage is thin (npm install --save-dev --save-exact babel-plugin-react-compiler@latest) and upgrading deliberately.

babel.config.js
module.exports = {
  plugins: [
    "babel-plugin-react-compiler", // must run first!
    // ...other plugins
  ],
};

Notes on each:

  • Babel: the compiler must be the first plugin, because it needs the original source before other transforms rewrite it.
  • Vite: @vitejs/plugin-react 6 removed the old inline babel option, so the compiler runs through @rolldown/plugin-babel with the reactCompilerPreset that plugin-react exports. On older plugin-react versions you'd write react({ babel: { plugins: ["babel-plugin-react-compiler"] } }) instead. npm create vite@latest also offers a compiler-enabled template.
  • Next.js Next.js 16: reactCompiler: true became a stable top-level option in Next.js 16 (it was experimental.reactCompiler before). It's off by default, and you still install the Babel plugin. Next.js uses an SWC-based pre-pass so the compiler only runs on files that need it (those with JSX or hooks), which keeps the build cost small. reactCompiler: { compilationMode: "annotation" } passes options through. create-next-app offers a compiler-enabled template.
  • Expo SDK 54 and later enable the compiler by default.

To check it's working, open React DevTools: optimized components show a Memo ✨ badge in the Components tab.

Configuration#

Options go in the plugin's options object (["babel-plugin-react-compiler", { ... }], or the object form of reactCompiler in Next.js). Four matter.

compilationMode: what gets compiled#

ModeCompiles
'infer' (default)Functions annotated with "use memo", plus functions named like components (PascalCase) or hooks (use prefix) that create JSX or call hooks.
'annotation'Only functions with a "use memo" directive. Good for opting in one component at a time.
'syntax'Only Flow's component and hook syntax. Requires Flow; doesn't work with TypeScript.
'all'Every top-level function. Not recommended: it compiles non-React functions too.

This editor runs in annotation mode. Only Fast opts in:

Annotation mode: opt in with "use memo"
babel-plugin-react-compiler 1.0
App.tsx (your code)
compiled output
Runs exactly the code on the right, with react/compiler-runtime.

Directives: "use memo" and "use no memo"#

Directives are string literals at the top of a function body (or the top of a file, to cover the whole module). "use memo" opts a function in; it's what annotation mode looks for, and in infer mode it forces compilation of a function the heuristics would miss. "use no memo" opts a function out in every mode, and a function-level directive overrides a module-level one.

react.dev's guidance on "use no memo" is that it's a temporary escape hatch: add it with a comment saying why and a tracking issue, fix the underlying problem, then remove it.

function LegacyChart({ data }) {
  "use no memo"; // TODO(#1234): mutates `data` in place; remove after the chart refactor
  // ...
}

target: which React version you run#

The output imports c from react/compiler-runtime, which exists in React 19. target defaults to '19'. For '18' or '17', the compiler imports from the react-compiler-runtime package instead, so you install it as a regular dependency, not a dev dependency, because it runs in the browser:

babel.config.js
// npm install react-compiler-runtime@latest
module.exports = {
  plugins: [["babel-plugin-react-compiler", { target: "18" }]],
};

panicThreshold, gating and logger#

panicThreshold is covered above. gating wraps each compiled function in a runtime check against a feature-flag function you provide, so the compiled and original versions both ship and the flag picks one per user: useful for an A/B test of the compiler itself. logger receives compile events, for build-time reporting.

babel.config.js
module.exports = {
  plugins: [
    ["babel-plugin-react-compiler", {
      panicThreshold: "none",
      gating: { source: "./feature-flags", importSpecifierName: "isCompilerEnabled" },
    }],
  ],
};

The ESLint rules#

The compiler's validation is also available as lint rules, and they're the most useful part to adopt first. They live in eslint-plugin-react-hooks (if you used the separate eslint-plugin-react-compiler before, remove it; these rules replace it). The compiler-powered rules ship in the recommended and recommended-latest presets, next to the familiar rules-of-hooks and exhaustive-deps.

eslint.config.js
import reactHooks from "eslint-plugin-react-hooks";
import { defineConfig } from "eslint/config";

export default defineConfig([reactHooks.configs.flat.recommended]);

A few of the rules: purity (known impure calls during render), immutability (mutating props, state and other immutable values), refs (reading or writing refs during render), set-state-in-render, set-state-in-effect, globals (mutating globals during render), preserve-manual-memoization, incompatible-library and unsupported-syntax. The linter doesn't need the compiler installed, so it's safe to turn on today. A reported error means the compiler would skip that component; fixing it means the compiler can optimize it, and usually removes a latent bug too.

Adopting it in an existing codebase#

A codebase that's been around for years has rule violations in it. The compiler won't break the build over them (with the default panicThreshold), but some of them change behavior once memoization kicks in, like the timestamp above. So roll it out the way you'd roll out any risky change:

  1. Lint first. Turn on the recommended preset of eslint-plugin-react-hooks and fix what it finds, starting with refs, purity, immutability and set-state-in-render. This is valuable even if you never ship the compiler.

  2. Start small. Either apply the compiler to one directory with Babel overrides, or use compilationMode: 'annotation' and opt in component by component with "use memo":

    babel.config.js
    module.exports = {
      overrides: [
        { test: "./src/modern/**/*.{js,jsx,ts,tsx}", plugins: ["babel-plugin-react-compiler"] },
      ],
    };
  3. Gate it in production if you want data: gating lets you compare compiled and uncompiled builds on real users, measured with the field metrics from chapter 28 (INP especially).

  4. Rely on end-to-end tests, not unit tests of render counts. The failures to look for are effects firing more or less often than before, and UI that stopped updating because it secretly depended on re-renders.

  5. Leave existing useMemo and useCallback in place. react.dev's advice: removing them can change the compiled output, so remove them only with testing.

  6. Use "use no memo" for the few components that misbehave, with a TODO, and fix them.

  7. Expand to more directories, then switch to the default infer mode across the app. Confirm with the Memo ✨ badge and measure.

Is it production-ready?#

Yes. The facts:

  • React Compiler 1.0 shipped as stable on October 7, 2025. The editors on this page run babel-plugin-react-compiler 1.0.0; check npm for the latest patch before you pin. It supports React 17 and later (with target and react-compiler-runtime below 19).
  • It runs in production at Meta, including the Meta Quest Store, where the team reported initial loads and cross-page navigations up to 12% faster, some interactions more than 2.5 times faster, and neutral memory use. react.dev also links case studies from Sanity Studio and Wakelet, and adds "your mileage may vary".
  • The ecosystem defaults are moving to it: Expo SDK 54+ turns it on by default, Next.js made reactCompiler stable in version 16, and create-vite and create-next-app offer compiler templates. react.dev says that "in the future some features may require the compiler in order to fully work."

The caveats, also from react.dev:

  • It assumes the Rules of React. Code that breaks them in ways static analysis can't detect (impure renders, mutation of shared objects) can behave differently once memoized, most visibly effects over- or under-firing. The health of your codebase decides how smooth adoption is.
  • Upgrades can change memoization. Pin an exact version if your test coverage is weak, and upgrade on purpose.
  • Build cost. It's a Babel plugin, so builds that otherwise avoid Babel pay something. Next.js's SWC pre-pass keeps that small, and Next.js 16.3 added an experimental Rust port that runs inside Turbopack (experimental.turbopackRustReactCompiler), covered in Rendering and deploying Next.js.
  • Libraries with interior mutability need care, as above.

So the senior answer is: yes for new apps, turned on from day one, with the lint rules enforced; and yes for existing apps, rolled out incrementally behind the linter and end-to-end tests, measured before and after.

Does it make useMemo and useCallback obsolete?#

Mostly, for performance. react.dev's guidance for new code is to rely on the compiler and use useMemo and useCallback only where you need precise control. Those cases:

  • Effect dependencies. If an object or function is a dependency of an effect, and the effect must not re-run unless the value meaningfully changes, useMemo/useCallback makes that intent explicit and guaranteed regardless of how the compiler groups scopes. This is the example react.dev gives. (Often the better fix is to depend on primitives or move the object into the effect.)
  • Code the compiler doesn't compile: files outside the compiled directories, components it bailed out of, "use no memo" functions, or non-component, non-hook functions.
  • Identity a library relies on, where a third-party API compares a value by reference across renders and you want that stability to be explicit rather than an artifact of compilation.
  • Existing code, which you leave alone until tested.

And memo itself: react.dev says you can safely remove React.memo with the compiler on, since it caches the child elements. The structural advice from chapter 29 still stands; it makes code simpler with or without a compiler.

Pitfalls#

Check your understanding#

PredictA skipped child under a compiled parent

In the rule-breaking example above, RenderCounter reads a ref during render and the compiler skips it. You run the compiled output and click the button three times. What does RenderCounter show, and why? What would it show without the compiler?

Build itCompile it by hand

Rewrite Results the way the compiler would: get a cache with c(n) from react/compiler-runtime, and use slot checks so that filterBooks only runs when query changes. Typing in the note must not run the filter again; typing in the search must still update the list. Press Check when it works.

import { useState } from "react";
import { filterBooks } from "./lib";

function Results({ query }: { query: string }) {
  const visible = filterBooks(query);
  return (
    <ul>
      {visible.map((b) => (
        <li key={b.id}>{b.title}</li>
      ))}
    </ul>
  );
}

export default function App() {
  const [query, setQuery] = useState("");
  const [note, setNote] = useState("");
  return (
    <div>
      <input aria-label="search" value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Search" />
      <input aria-label="note" value={note} onChange={(e) => setNote(e.target.value)} placeholder="Note" />
      <Results query={query} />
    </div>
  );
}
Quick checkA component the compiler can't compile

With the default configuration, what happens when the React Compiler finds a component that reads ref.current during render?

Quick checkOpting in gradually

You want the compiler to touch only the components your team explicitly marks, while you clean up the rest. Which setup does that?

Explain it out loudHow does the React Compiler work?

An interviewer asks: "What does the React Compiler actually do to my code?" Answer in about a minute, including one thing it can do that useMemo can't.

Explain it out loudShould we turn it on?

Your tech lead asks: "Is the React Compiler production-ready, and should we turn it on in our four-year-old app?" Answer in about a minute.

Interview angle

Say it in 30 seconds

The React Compiler is a build-time Babel plugin that memoizes components and hooks for you. It lowers each one into a control-flow-graph intermediate representation, works out which values are reactive and where objects are mutated, groups the work into reactive scopes, and emits a per-component cache: const $ = _c(n), then a dependency check per scope that either recomputes and stores or loads from the cache. Because it caches JSX elements, unchanged children are skipped without memo. It depends on the Rules of React, skips code that visibly breaks them, and has been stable since 1.0 in October 2025.

What problem does the React Compiler solve, and what does it do to your code?

basic

Walk me through how the compiler works internally.

senior

What happens when code breaks the Rules of React under the compiler?

senior

Is the React Compiler production-ready? Would you enable it?

intermediate

Does the compiler make useMemo and useCallback obsolete?

intermediate

How do you configure the compiler and adopt it in an existing codebase?

intermediate

Recap#

  • The React Compiler is a build-time Babel plugin that memoizes components and hooks automatically. It's stable (1.0, October 7, 2025) and runs in production at Meta.
  • It lowers code to a control-flow-graph HIR, infers reactive values and mutation, groups work into reactive scopes, and emits const $ = _c(n) plus a dependency check per scope. Slots start as a sentinel, and caching JSX elements is how it skips children without memo.
  • It depends on the Rules of React: pure renders, immutable props and state, the Rules of Hooks. Detected violations make it skip that function (with the default panicThreshold: 'none'); undetected ones can change behavior, so use the eslint-plugin-react-hooks rules.
  • Set it up with the Babel plugin (first in the pipeline), Vite's reactCompilerPreset through @rolldown/plugin-babel, or Next.js reactCompiler: true (stable since 16, off by default). Configure compilationMode, target (with react-compiler-runtime for 17 and 18), panicThreshold, and the "use memo" / "use no memo" directives.
  • Adopt it incrementally: lint, then a directory or annotation mode, end-to-end tests, measure, expand. Manual useMemo/useCallback remain escape hatches, mainly for effect dependencies and uncompiled code.

Sources#