Skip to the page

Performance: measure, then fix · mid

Re-renders, memo and the React Compiler

A component re-renders when its parent renders, its state changes or a context it reads changes; React.memo skips a render only when every prop is shallow-equal (Object.is), so new objects and inline functions defeat it, and the React Compiler now adds most of that memoization automatically.

The notes

What you must know

  • Each parent render creates new object, array and function identities. React.memo compares props with Object.is, so { inStock: true } !== { inStock: true }.
  • Fixes, cheapest first: move state down (keep the fast-changing input in its own component), hoist constant objects out of the component, then useMemo/useCallback for values passed to memo children.
  • Context: every consumer re-renders when the value identity changes. Memoize the value, split fast-changing values into their own context, or use a selector store (Zustand, Redux).
  • React Compiler 1.0 (Oct 2025) auto-memoizes components and hooks that follow the Rules of React. Expo SDK 54+ templates enable it (experiments.reactCompiler); opt a file or component out with "use no memo". It does not touch node_modules.
  • With the compiler on, use Reanimated shared values through get()/set() rather than .value.
  • Find re-renders: "highlight updates" and the Profiler in React Native DevTools; compiled components show a "Memo ✨" badge.
  • Memoization is not free (memory and comparisons). Measure before wrapping everything.

The red pen

Common traps: mistake → fix

  • Mistake: "React.memo compares deeply"

    Fix: it is shallow: Object.is per prop.

  • Mistake: "useCallback makes a function faster"

    Fix: it only keeps the same identity; it helps only when a memo child or an effect depends on it.

  • Mistake: "With React Compiler I never think about renders"

    Fix: components that break the Rules of React are skipped, and context/state design still matters.

Easy to hard

Questions interviewers ask, easy to hard

  1. Why does this child re-render on every keystroke? Fix it two ways.
  2. When does memoization cost more than it saves?
  3. What does React Compiler do, and what can it not optimize?
  4. How do you find unnecessary re-renders on a device?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview