React Compiler 1.0 and the useMemo I Got to Delete
The compiler memoizes for you at build time. What to remove, what to keep, and the rule it quietly enforces.
React Compiler hit 1.0 this month. It reads your components at build time and adds memoization where it's safe, so you stop writing most useMemo, useCallback, and React.memo by hand.
I've been trying it on a data-heavy React app, the kind with long filtered tables and React Query everywhere. Here's what changed in practice.
What it actually does
Take a typical list screen:
function Orders({ orders, status }: Props) {
const visible = useMemo(() => orders.filter((o) => o.status === status), [orders, status]);
const onSelect = useCallback((id: string) => setSelected(id), []);
return <OrderTable rows={visible} onSelect={onSelect} />;
}With the compiler on, you can write it the obvious way:
function Orders({ orders, status }: Props) {
const visible = orders.filter((o) => o.status === status);
const onSelect = (id: string) => setSelected(id);
return <OrderTable rows={visible} onSelect={onSelect} />;
}The compiler caches visible and onSelect and only recomputes them when orders or status change. It also memoizes the JSX, so OrderTable skips re-rendering when nothing it receives changed. That's more granular than most of us bothered to do by hand.
Turning it on
In Next.js 16 it's one config line:
const nextConfig = { reactCompiler: true };Elsewhere it's a Babel plugin, babel-plugin-react-compiler, and Vite can run it through the React plugin's Babel option. It works best on React 19. Older versions down to 17 need the small react-compiler-runtime package.
The rule it enforces: components must be pure
The compiler assumes your code follows the Rules of React. The big one: don't mutate things during render.
// breaks the compiler's assumptions
function Total({ items }: Props) {
items.sort((a, b) => a.price - b.price); // mutates a prop
return <p>{items[0].price}</p>;
}When the compiler sees code like this, it doesn't crash. It skips optimizing that component and moves on. That's safe, but it's silent. To see where it gave up, turn on the lint rules. They now ship in eslint-plugin-react-hooks as part of the recommended config, and they're worth enabling even if you never turn the compiler on. Each warning is a real bug waiting for a re-render to expose it.
What I deleted, and what I kept
Deleted:
useMemoaround filters, maps, and sorts.useCallbackfor handlers passed to child components.- Most
React.memowrappers on table rows and list items.
Kept:
useMemowhose result feeds an effect's dependencies. The compiler handles this too, but I'd rather the intent stay visible in the code for now.- React Query's
select. It's about what the query returns and when it notifies, not about render memoization. - Anything that profiled slow before. Delete the manual memo, profile again, and only then move on.
If one component misbehaves after the switch, "use no memo" at the top of the function opts it out while you find out why.
Is it worth turning on?
For an existing app, start with the lint rules, fix what they flag, then enable the compiler. The fixes are the valuable part either way. The memoization is a bonus you get once your components are honest about being pure.
Keep reading
All posts2025
3 min
Server State Is Not App State
What changed once I stopped putting API data in a global store and let TanStack Query own it. Keys, invalidation, and the two settings that matter most.
reactfrontend3 min
React 19 Actions Replaced My Form Boilerplate
Pending flags, error state, optimistic rows, and a reset after submit. I used to write all of it by hand for every form. React 19 turned most of it into three hooks and a function passed to the form.
reactfrontend