Engineering / react-compiler
Write and review React code as if the React Compiler is enabled.
The compiler memoizes. You do not.
In any React 19+ codebase with the compiler enabled, do not add useMemo, useCallback, or React.memo by default. The compiler handles memoization at finer granularity than a human writes, and adding manual versions is at best noise. This is the most common failure mode in LLM-generated React: the bulk of any agent's React training corpus is pre-compiler, so the default output skews toward manual memoization.
Write components plainly:
tsxfunction DashboardRow({ entity, onSelect }) {const label = formatLabel(entity);const total = entity.items.reduce((sum, i) => sum + i.value, 0);return (<Row onClick={() => onSelect(entity.id)}><Label>{label}</Label><Total>{total}</Total></Row>);}
Not:
tsxconst DashboardRow = memo(({ entity, onSelect }) => {const formatted = useMemo(() => ({ /* ... */ }), [entity]);const handleClick = useCallback(() => onSelect(entity.id), [entity.id, onSelect]);return /* ... */;});
The compiler produces the equivalent of the first from any input that follows the Rules of React. Adding the second by hand is noise and can interfere with the compiler's analysis.
Keep manual useMemo or useCallback only in these cases:
addEventListener, an IntersectionObserver, third-party libraries with their own === checks, anything outside React that retains the reference.Anything outside these three cases gets deleted. The React team's own guidance is the same split: rely on the compiler in new code, and in existing code either leave memoization in place or test before removing it, because removal can change the compiled output.
next.config (top-level reactCompiler: true since Next.js 16; experimental.reactCompiler only on 15.x), vite.config (@vitejs/plugin-react v6 removed the inline babel option, so look for reactCompilerPreset via @rolldown/plugin-babel, or the experimental native react({ compiler: true })), babel.config (babel-plugin-react-compiler), or Expo (on by default from SDK 54). If not enabled, propose enabling first. Do not strip memoization on a compiler-off codebase.eslint-plugin-react-hooks is at v7+. The compiler rules merged in from the retired eslint-plugin-react-compiler in late 2025, and v7 turned them all on in recommended.error. recommended ships the compiler rules at error except unsupported-syntax and incompatible-library, which stay at warn. See lint-setup.md for the strict configuration.useMemo, useCallback, React.memo that do not match one of the three exceptions, one component at a time, with tests or a profiler check after each.logger (CompileError events) or check for the Memo badge in React DevTools. Skips cascade: fixing an upstream skip can reveal a second issue downstream. First run gives the count. Subsequent runs give the truth."use no memo" directives. Each is a performance cliff with a TODO behind it. Grep the count over time as a health metric.Five patterns drop the surrounding function out of compilation. Lint catches some of them; the rest are compiler todo bails that only the compiler logger or DevTools reveal. Full list, code examples, and fixes in exceptions.md.
file: <path>findings:- removed: <useMemo | useCallback | memo> @ <line>, compiler handles- kept: <useMemo | useCallback> @ <line>, reason: <ref-identity | expensive | effect-dep>silent bails detected:- <pattern> @ <line>: <one-line fix>
Based on The React Compiler at Eighteen Months. Sibling detail in exceptions.md and lint-setup.md.