Chapter 4 · Practice 1 of 5
Turn on React Compiler instead of memoizing by hand
Why it matters
React Compiler 1.0 has been stable since October 2025. It analyzes your components at build time and adds memoization automatically, which removes most of the need for manual useMemo, useCallback and React.memo. It works best with React 19 and also supports React 17 and 18.
To set it up:
- Fix lint errors first: the compiler assumes your code follows the Rules of React.
- Install
babel-plugin-react-compilerand enable it in your build. - In Next.js set
reactCompiler: true. Vite and Expo have their own setup, and Expo SDK 54 and later enable it by default. - Verify it is working with React DevTools, which marks compiled components.
See the installation guide for each build tool.
Do
- Enable the compiler-powered lint rules in
eslint-plugin-react-hooks - Roll it out on one directory first if your codebase is large
Example
// next.config.ts
import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
reactCompiler: true,
};
export default nextConfig;