Lesson 28 of 80
Before you can fix an unnecessary re-render, you need the actual short list of what triggers one in the first place — it's smaller and more specific than most intuitions.
13 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 2
Is 'a prop changed' its own separate, fourth cause of a re-render, alongside own state, parent re-render, and context change?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
A component re-renders for exactly one of these reasons:
useState/useReducer setter called with a genuinely new value).Provider above it).That's the whole list. Notably: a prop changing isn't its own separate cause — it's a consequence of reason 2 (the parent re-rendered and passed something different this time).
function Parent() {
const [count, setCount] = useState(0);
return (
<div>
<button onClick={() => setCount(count + 1)}>{count}</button>
<ExpensiveChild /> {/* re-renders every time count changes — even though it uses no props at all */}
</div>
);
}
ExpensiveChild takes no props and reads no state — yet it re-renders on every click, purely because reason 2 applies: its parent re-rendered. This is default, expected React behavior, not a bug — React.memo (from the memoization lesson) is the tool that opts a component out of reason 2 specifically, by adding a shallow props comparison before deciding whether to actually re-render.
A component re-renders for exactly one of three reasons — nothing else triggers it.
React.memo everywhere as a reflex.useContext on a Provider whose value changed."What causes a React component to re-render?" is a foundational question that a surprising number of candidates answer incompletely (usually forgetting reason 2) — getting the full, precise list right is what makes every later performance discussion (memo, useMemo, useCallback) make sense.