Re-render
In one line
A re-render occurs when a component's state or props change, or when a parent re-renders — causing the component function to run again.
In simple words
A component re-renders (its function runs again) when: (1) its own state changes (via a setState call), (2) its props change (because the parent re-rendered and passed new props), or (3) its parent re-renders (by default, children re-render when the parent does).
This third case is the most common source of unnecessary re-renders. If a parent changes state that only it cares about, all children still re-render even if their props are identical. React.memo prevents this by skipping the re-render when props are unchanged.
To minimize re-renders: keep state close to where it's used, split components so only the parts that need to update do, use React.memo for expensive children, and avoid passing new object/array/function references as props on every render.
Example
function Parent() {
const [count, setCount] = useState(0);
return (
<div>
<button onClick={() => setCount(c => c + 1)}>Inc</button>
<Child /> {/* Re-renders every time count changes, even though
Child has no props and doesn't use count */}
</div>
);
}Every click changes count, causing Parent to re-render, which causes Child to re-render even though Child's props haven't changed.
Related terms
Related Resources
Related Lessons
- Performance Optimization
Learn to reduce unnecessary re-renders.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.