Intermediate React Interview QuestionsIntermediateConcept
React · Question 52
What does React.memo do, and what does it not prevent?
Direct answer
memo can skip a child render when its parent re-renders and the child's props are unchanged, but it does not block renders caused by the child's own state or context changes.
Row.jsx
const Row = memo(function Row({ item }) {
return <li>{item.name}</li>;
});- Can skip: a parent-driven render when props compare equal.
- Cannot skip: updates caused by the memoized component's own state.
- Cannot skip: updates from context values that the component reads.
- Requirement: rendering must already be pure; memo is an optimization, not a correctness tool.