React Best Practices

Chapter 4 · Practice 1 of 5

Turn on React Compiler instead of memoizing by hand

From Performance and memoization

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:

  1. Fix lint errors first: the compiler assumes your code follows the Rules of React.
  2. Install babel-plugin-react-compiler and enable it in your build.
  3. In Next.js set reactCompiler: true. Vite and Expo have their own setup, and Expo SDK 54 and later enable it by default.
  4. 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

TypeScript
// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  reactCompiler: true,
};

export default nextConfig;