React Compiler mental model and setup
React Compiler is a build-time optimizer for React components and Hooks. Its main job is to apply memoization automatically when analysis proves reuse is safe.
It is not a scheduler, state manager, cache server, or replacement for component architecture.
Stable status
React Compiler 1.0 is stable and production-ready. It works with React and React Native and can optimize components and Hooks without requiring an architectural rewrite.
The compiler is optional: React works without it.
What automatic memoization means
function ProductCard({ product }) {
const details = expensiveFormat(product);
return <Card details={details} />;
}
The compiler may preserve derived work or JSX when the relevant reactive inputs have not changed.
You normally do not write the generated memo cache code yourself.
What the Compiler does not fix
Memoization avoids repeating work. It does not change the complexity of the underlying work.
Rules of React are the foundation
Compiler analysis relies on React's programming model:
- render is pure and idempotent;
- props/state are immutable snapshots;
- Hooks follow stable call-order rules;
- refs are not used as render-time mutable state;
- component identities stay stable;
- external side effects stay outside render.
When unsupported or unsafe patterns are found, the compiler can skip affected functions rather than requiring an all-or-nothing migration.
Installation
npm install -D babel-plugin-react-compiler@latest
Basic Babel configuration:
module.exports = {
plugins: ['babel-plugin-react-compiler'],
};
The compiler should run before transforms that destroy source structure it needs to analyse. Framework integrations may configure this for you.
React version targeting
React 19 is the default target.
[
'babel-plugin-react-compiler',
{ target: '19' }
]
For React 17 or 18, use the compatible compiler runtime and matching target according to the current Compiler documentation.
Verify that Compiler is actually running
Do not assume installation equals effective compilation.
Compiler does not mean “zero renders”
A component can still render because:
- its own state changes;
- context changes;
- inputs genuinely change;
- Suspense/retries happen;
- Strict Mode development checks run;
- concurrent rendering prepares work that may not commit.
The goal is not a magical render count. The goal is less unnecessary repeated work while preserving React semantics.
Measure architecture before micro-optimizing
If a screen is slow, still inspect:
- state ownership and render blast radius;
- DOM/list size and virtualization needs;
- expensive algorithms;
- network/data waterfalls;
- Suspense/loading architecture;
- client bundle size;
- browser main-thread work.
Compiler optimization is one layer in the performance stack.
Incremental adoption principle
You do not need to fix every legacy component before gaining value from Compiler.
Common mistakes
- expecting the Compiler to fix impure render code;
- measuring success only by render count;
- deleting all manual memoization immediately;
- assuming framework configuration is active without verification;
- using Compiler to avoid fixing huge DOM trees or poor state scope;
- ignoring ESLint diagnostics because the app “still works.”
Production checklist
- Compiler version/configuration is pinned and reviewed;
- current
eslint-plugin-react-hooksrules are active; - CI builds the compiler-enabled path;
- tests cover behavior, not implementation details;
- profiling compares meaningful user interactions;
- rollout can be narrowed or disabled if a compatibility issue appears;
- Rules of React violations are treated as correctness issues, not performance trivia.
Interview questions
Junior: Is React Compiler a runtime feature?
Mid-level: What does automatic memoization actually reuse?
Senior: How would you introduce React Compiler into a large React 19 codebase without conflating memoization gains with architectural performance problems?