Skip to the page

Performance · core

Why a component re-renders

A component re-renders when its own state changes, when its parent re-renders, when a context it reads changes, or when an external store it subscribes to changes; a props change alone is not a cause, and a re-render is not a DOM update.

The notes

What you must know

  • Every re-render starts with a state change somewhere. When a component re-renders, by default all its descendants re-render too, whether their props changed or not.
  • The four causes: own state (useState/useReducer), parent re-render, context value change, external store change (useSyncExternalStore, Redux, Zustand).
  • "It re-renders because its props changed" is a myth: children re-render because the parent did. memo is what makes props matter.
  • A re-render produces a new description of the UI; React then changes only the DOM nodes that differ. Usually re-renders are cheap; they matter when they are frequent and expensive.
  • Measure before fixing: React DevTools Profiler ("why did this render?", commit durations), React Performance Tracks in Chrome DevTools (19.2), and INP from real users.
  • Structural fixes first: move state down to where it is used; lift content up by passing children; split context. Then memoize where needed.
  • In apps compiled with the React Compiler, many unnecessary child re-renders disappear automatically, but the causes above are still the mental model.

The red pen

Common traps: mistake → fix

  • Mistake: "It re-renders when props change"

    Fix: it re-renders when its parent re-renders; props only matter with memo.

  • Mistake: "Every re-render touches the DOM"

    Fix: only the differences are committed.

  • Mistake: "Wrap everything in memo/useCallback"

    Fix: costs memory and comparisons; measure first.

Easy to hard

Questions interviewers ask, easy to hard

  1. What causes a React component to re-render?
  2. Does a component re-render when its props change?
  3. This component re-renders 47 times a second. What do you do first?
  4. Fix it without memo.
  5. When is a re-render actually a problem?

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