Virtual DOM
The Virtual DOM is a lightweight, in-memory representation of the real page that React keeps and updates. React compares the new virtual tree to the previous one and changes only the parts of the actual page that differ.
React
Directly updating the browser's real DOM is slow, and doing it inefficiently can make apps sluggish. React solves this by building a virtual copy of the UI in memory first.
When state or props change, React builds a fresh virtual tree, compares it to the old one (a process called reconciliation), and figures out the minimal set of real DOM changes needed. This lets you write code as if the whole UI re-renders every time, while React keeps it fast under the hood.
Examples
JSX — Illustrates the concept: React applies just the minimal real DOM update rather than rebuilding the entire list.
// You change state...
setItems([...items, newItem]);
// React diffs the virtual DOM and only inserts
// the single new <li>, leaving the rest untouched.