Render Does Not Mean DOM Update
What you'll learn: React can render a component multiple times without ever touching the real DOM if nothing actually changed.
The Mental Model Trap
When beginners hear "React re-renders your component," they often imagine the browser frantically repainting pixels and updating the DOM. This is wrong. A render in React simply means calling your component function to generate a new description of what the UI should look like.
Rendering vs. Committing (Again)
You've learned that React has two phases: render and commit. Here's the crucial insight: the commit phase only happens if something changed.
After React calls your component function (the render), it compares the new output to the previous output. If they're identical—same elements, same props, same structure—React skips the DOM update entirely. Your component ran, but the browser DOM stayed untouched.
The Analogy
Think of a movie director reviewing a scene:
- Rendering: The actors perform the scene again
- Comparing: The director checks if this take differs from the last one
- Committing: Only if something changed does the director actually use the new footage
The actors performed (your component rendered), but if the performance was identical, nothing makes it to the final cut (no DOM update).
Why This Matters
This is why setting state to the same value doesn't cause visible updates—React renders, sees nothing changed, and bails out of the commit. It's also why you can render thousands of times per second in development without the browser exploding: most renders don't result in DOM work.
Key Takeaway: Rendering is cheap (calling a function); DOM updates are expensive. React only does the expensive part when the output actually differs.