0
Challenge · 91React Internals
Virtual DOM
Internalsused in ~60% of apps
Touching the real DOM is slow and you never know which node actually changed. So instead of mutating the page directly, React describes the whole UI as a cheap JavaScript object every render, compares it to the last description, and changes only the real nodes that differ.
Core idea. The Virtual DOM is your UI represented as a lightweight tree of plain JS objects. On each render React builds a fresh tree, diffs it against the previous one (reconciliation), and applies the minimal set of real-DOM operations needed to match it.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
VDOM NODES RE-DESCRIBED
4
every render, cheap JS objects
REAL DOM MUTATIONS
0
only what actually differs
NEW VDOM TREE (rebuilt every render)
<article class="card">
<h3>Pulse</h3>
<span>0 likes</span>
<button>Like</button>
diff0 changed
REAL DOM (only diffs applied)
<article class="card">untouched
<h3>Pulse</h3>untouched
<span>0 likes</span>untouched
<button>Like</button>untouched
rendered 1×
Every render React re-describes the whole tree as plain JS objects (left), then diffs it against the previous one and touches the real DOM only where they differ (right). Hit Re-render, same state: React still rebuilds and diffs the entire tree, yet applies zeroDOM mutations — proof the VDOM is a bookkeeping step, not free magic.
↑ play a little first, then dig in