Avoiding Unnecessary Re-renders
Learn the common causes of unnecessary component re-renders and the standard techniques to prevent them.
An 'unnecessary' re-render is one where a component re-executes and reconciles even though its actual rendered output wouldn't change, wasting CPU time. The most common causes are: a parent re-rendering and passing new object/array/function literal props by reference every time, a Context value changing and re-rendering every consumer regardless of relevance, and state living higher in the tree than it needs to (not colocated).
It's like a manager who reflexively calls an all-hands meeting (a broad re-render) every time any single decision changes, versus one who only pulls in the specific people whose work is actually affected — the second approach gets the same outcome with far less wasted time from everyone who didn't need to be involved.