What is the React Compiler (React Forget)?

Answer

The React Compiler (codenamed React Forget, now in beta as of 2024) is a Babel/webpack plugin that automatically adds memoization to React components and hooks — eliminating the need to manually write useMemo, useCallback, and React.memo. The compiler analyzes the component's data flow statically and inserts memoization at the right granularity — often more precisely than humans would. It understands React's semantics (rendering, state, props, hooks) and can determine which values are stable vs. which change on every render. How it works: the compiler transforms your React component into one that automatically caches its computations and skips work when inputs have not changed. Requirements: your code must follow React's rules (pure renders, correct hook usage) — the compiler cannot optimize code that violates rules. Impact: most apps will see significant performance improvements without code changes; the codebase becomes simpler (fewer memo/useCallback/useMemo calls); developers spend less time on manual performance tuning. Meta has shipped the compiler internally with large performance gains. It is progressively being rolled out to the ecosystem.