Skip to content
Back to Pathway
renderingintermediate

Component Re-rendering

A re-render occurs when React calls a component function again to compute its updated Virtual DOM subtree.

Mental Model

"The Refresh: Refreshing the weather dashboard repaints current temperatures without needing to rebuild the entire computer screen."

Interactive Engine Walkthrough

Walkthrough Idle
Click "Animate Update" to play the state reconciliation walkthrough.

Reference Code Snippet

Component.jsx
JSX / React 19
1function Parent() {
2  const [count, setCount] = useState(0);
3  console.log("Parent rendered");
4
5  return (
6    <div>
7      <button onClick={() => setCount(c => c + 1)}>
8        Update State
9      </button>
10      <Child />
11    </div>
12  );
13}
14
15function Child() {
16  console.log("Child rendered");
17  return <p>I am a child</p>;
18}
Technical Takeaways & Best Practices
  • 01.By default, when a parent component re-renders, all of its descendant children also re-render.
  • 02.Re-rendering is NOT the same as real DOM painting; React only touches real DOM if the output changed.
  • 03.State changes, prop updates, and context consumption are the 3 main triggers for re-renders.

01. The Chain Reaction

A re-render is triggered by three things: **State Change**, **Prop Change**, or **Context Change**. By default, when a parent component re-renders, React recursively re-renders **all** of its children, regardless of whether their props changed. This ensures the UI remains consistent with the latest logic.

Render Cascade

Parent (State Update)
↓
Child A
Child B

02. Virtual vs Real DOM

It's important to distinguish between **Rendering** (calculating the VDOM) and **Painting** (updating the screen). React might re-render a component 100 times, but if the VDOM output is identical, the browser's Real DOM isn't touched. This is why "unnecessary re-renders" are often less expensive than they seem, though they should still be managed in heavy apps.

Architectural Advice

"Don't reach for 'memo' or 'useCallback' prematurely. React is incredibly fast. Focus on clean data structures first, and only optimize when you detect visible jank using the Profiler."