React Compiler is a tool that automatically memoizes your code (React 19+). Previously, developers manually added useMemo, useCallback, React.memo. The compiler does it itself.
Simple analogy: Imagine you are writing a letter by hand. Before the compiler:
What the compiler does:
Before (with compiler — manually):
1const sorted = useMemo(() => list.sort(), [list]);2const handleClick = useCallback(() => doSomething(), []);3const Memoized = React.memo(MyComponent);
Now (with compiler):
1const sorted = list.sort(); // Compiler will understand what to memoize2const handleClick = () => doSomething();3<MyComponent /> // Compiler will memoize automatically
Advantages:
Disadvantages: