DEV Community

Monalisa Das
Monalisa Das

Posted on

Stop manually memoizing every callback — the React Compiler already does it better than you can.

The React Compiler does your memoization better than you do. Stop wrapping every callback in useCallback "just in case."

React 19's compiler statically analyzes your component tree at build time and inserts exactly the right memoization - no dependency arrays to maintain, no closures retained longer than necessary, no guesswork. Hand-rolling it adds three things: cognitive load for the next person reading the code, a dependency array that will silently go stale, and closure memory pressure from retaining an entire scope you didn't mean to.

Most re-renders are cheap. The comparisons useMemo and useCallback add to "prevent" them have their own cost - one you haven't measured against the render you're trying to avoid.

"Wrap it just in case" was a reasonable heuristic in 2018. In 2025 with React 19 in production, it's solving a solved problem while leaving a dependency array for the next reviewer to audit and get wrong.

Profile first. Memoize second. Let the compiler handle the rest.

React Compiler — automatic memoization, reached 1.0 stable Oct 2025, now default in Next.js 16 / Vite / Expo templates:
react.dev/learn/react-compiler

Top comments (0)