The React Compiler and automatic memoization
How the stable React Compiler auto-inserts memoization and what it changes about writing useMemo, useCallback, and memo by hand.
The React Compiler and automatic memoization
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- The React Compiler is a build-time tool that reads your component code and automatically inserts the same kind of memoization you'd otherwise write by hand with useMemo, useCallback, and React.memo.
- It reached a stable 1.0 release in October 2025, after several years as an experimental project previously known as React Forget; it is no longer a preview feature, but adoption across existing codebases is still gradual.
- The compiler relies on your code already following the Rules of React (no mutating props or state, no side effects during render); eslint-plugin-react-compiler checks for violations and is the recommended first step before turning the compiler on.
- Turning it on is a build-tooling change, not a code change: it ships as a plugin for Babel, and is wired into Vite, Next.js, and other frameworks through their own compiler integrations, with no required edits to component code.
- For new code on a project that has adopted the compiler, the default should shift toward writing plain, unmemoized components and letting the compiler decide where memoization pays off, rather than reaching for useMemo and useCallback reflexively.
- Manual memoization isn't obsolete. The compiler only analyzes component and hook code it can see; a module-level expensive calculation, a plain utility function outside any component, or any codebase that hasn't adopted the compiler yet still need useMemo, useCallback, and React.memo written by hand.
What the compiler actually does
Every lesson in this group so far has been about writing memoization by hand: wrapping a calculation in useMemo, a function in useCallback, a component in React.memo, and getting the dependency arrays and prop references right so none of it silently falls apart. The React Compiler exists to do that work for you.
It’s a build-time tool — not something that runs in the browser — that reads your component and hook source code and rewrites it to insert the same category of memoization you’ve been writing by hand in this lesson group. Given a component like this:
function ProductList({ products, query }) {
const filtered = products
.filter((p) => p.name.toLowerCase().includes(query.toLowerCase()))
.sort((a, b) => a.price - b.price);
return (
<ul>
{filtered.map((p) => (
<li key={p.id}>{p.name} — ${p.price}</li>
))}
</ul>
);
}
the compiler can determine, from static analysis, that filtered only needs to be recomputed when products or query changes — the exact same reasoning you’d encode yourself with a useMemo dependency array — and inserts that caching automatically, without you writing useMemo at all. The same analysis extends to stabilizing function references and to wrapping components so they skip re-rendering when their props haven’t meaningfully changed, covering the ground of useCallback and React.memo as well.
Where it stands: stable, not universal
The React Compiler spent several years as an experimental project, first previewed under the internal name React Forget, before reaching a stable 1.0 release in October 2025. Stable means it’s no longer a preview or an early-adopter-only tool — it has a committed API and is recommended for production use — but it does not mean every React project has it turned on. Adoption is opt-in and gradual: a team enables it on an existing codebase, watches for regressions, and it’s reasonable for a project built over the past several years to still be running without it while migration is planned. Treat any specific claim about “how teams are currently adopting it” as something that keeps moving; what’s stable is the compiler’s existence and API, not a fixed adoption number.
Turning it on
Enabling the compiler is a build-tooling change, not a rewrite of your components. It ships as a Babel plugin, and the major frameworks wire that plugin in through their own build configuration — a Vite plugin, a Next.js config flag, and equivalents for other setups — so in the common case you add a dependency and a small config change rather than touching component code.
Before flipping it on, the recommended first step is adding eslint-plugin-react-compiler to your lint setup. The compiler’s safety guarantees depend on your code actually following the Rules of React that earlier lessons in this roadmap covered — not mutating props or state directly, keeping render free of side effects, and so on. Code that quietly breaks those rules today might work by accident without the compiler and misbehave once the compiler starts memoizing around it, so the lint plugin exists to surface those violations first, as a non-breaking pass over the existing codebase, before the compiler itself is turned on.
What this changes about the previous two lessons — and what it doesn’t
On a project that has adopted the compiler, the practical default shifts: write plain components without reaching for useMemo, useCallback, or React.memo, and let the compiler decide where memoization actually helps, based on its own analysis rather than your guess. This removes the exact failure mode the previous lesson spent most of its time on — a new object literal passed as a prop silently defeating React.memo — because the compiler’s analysis accounts for that pattern directly rather than relying on you to remember to wrap things.
It does not make the previous two lessons obsolete. The compiler only sees and transforms component and hook code; anything outside that boundary is invisible to it. A plain exported function that does an expensive calculation, a module-level constant computed at import time, or any class-based or non-component code still needs caching written by hand if it needs caching at all. And any codebase — including large, long-lived ones — that simply hasn’t adopted the compiler yet still depends entirely on the manual discipline from the previous two lessons. Understanding useMemo, useCallback, and React.memo by hand remains the foundation; the compiler is a way to stop having to apply that foundation manually everywhere it’s safe to automate, not a reason to skip learning it.
What the video covers
Jack Herrington’s video was recorded around the compiler’s stable 1.0 release and walks through what it automatically memoizes and what that means for writing useMemo, useCallback, and memo by hand going forward, demonstrated against a TanStack Start project. Because the demo is framed around that one router, the general adoption picture above — Babel plugin, framework integrations, the ESLint prerequisite — is written to generalize beyond the specific setup the video shows. For the deeper mechanics of how the compiler’s analysis decides what’s safe to memoize, the linked follow-up goes further, though it was recorded before the 1.0 release and its adoption framing is accordingly dated.
Where this fits
The last tool in this group for finding where memoization — manual or automatic — actually matters is measurement itself: profiling with React DevTools.
Check yourself
What does the React Compiler actually do to your code?
At build time it analyzes your components and hooks and automatically inserts memoization equivalent to useMemo, useCallback, and React.memo wherever it determines skipping recomputation is safe, so you don't have to write those calls by hand.
Why does the compiler require code to follow the Rules of React before it's turned on?
Its safety analysis assumes components and hooks behave the way React's own rules require — no mutating props or state directly, no side effects during render. Code that breaks those rules can be memoized incorrectly by the compiler, which is why eslint-plugin-react-compiler is used to catch violations before enabling it.
Does adopting the React Compiler mean deleting every existing useMemo and useCallback call in a codebase?
Not automatically. Existing manual memoization keeps working alongside the compiler without causing harm, and most teams leave it in place during migration and simply stop adding new manual memoization going forward, cleaning up old calls opportunistically rather than all at once.
What kind of code can the React Compiler not memoize for you?
A calculation that lives outside any component or hook, such as a plain exported utility function or a module-level constant computed once at import time. The compiler only analyzes component and hook bodies, so caching results in ordinary functions or modules still requires writing the caching logic yourself.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.