WhoBuilt

Auto Memoization in React Native? React Compiler Has You Covered

May 30, 2025· 8 min· 14K views·Watch on YouTube

Speaker

Michał Pierzchała, principal engineer at Callstack, explains how to use React Compiler to reduce unnecessary re-renders in React Native in an episode of Callstack’s React Native Optimization in Practice series.

Spotting unnecessary re-renders

Pierzchała introduces React Compiler as a React Core Team project that automatically memoizes code so React can re-render less without code changes. In a sample app, a button and text input update separate pieces of state, but changing either initially causes unrelated components to render. React Native DevTools’ Highlight Updates setting makes those renders visible.

Setting up React Compiler

Pierzchała says the compiler can apply optimizations developers might otherwise add with React.memo, useMemo, or useCallback. He follows the React Native optimization guide, installs the compiler as a Babel plugin, and configures it to target React 19 in a project using React Native 0.79. He then clears Metro’s cache and restarts the app so the new Babel configuration takes effect.

Checking the results in DevTools

After restarting, DevTools shows memo labels for the App, CountButton, and TextInput components. Updating the text no longer re-renders the button, and clicking the button does not re-render the text input. In the Profiler, Pierzchała records six commits and confirms that only the component whose props changed renders in the examples shown.

Applying it to React Native

Pierzchała notes that React Compiler can be used in React Native as well as React web projects. He closes by encouraging developers to apply the setup and profiling techniques in their own projects.

Takeaways

  • Use DevTools’ Highlight Updates to find components that render when unrelated state changes.
  • React Compiler is configured as a Babel plugin; set its target to match the project’s React version.
  • Clear Metro’s cache and restart after changing Babel configuration.
  • Use the React Profiler to check whether memoization prevents unrelated components from rendering.
  • Check compiler behavior in the app instead of assuming every render has been eliminated.

Mentioned in this talk

Search inside this talk

What was claimed 8

Related talks