Home
← All questions

Why is React fast? What is the Virtual DOM?

EasyPremiumReact

React interview practice: Explain the Virtual DOM, reconciliation, and why it makes React fast.

Answer

The Virtual DOM (VDOM) is a lightweight in-memory JavaScript representation of the real DOM. On each render React builds a new VDOM tree and diffs it against the previous one (reconciliation), then applies only the minimal set of changes to the real DOM in a batched update.

Why this is fast:

  • Direct DOM manipulation is expensive (layout/reflow/repaint). Batching minimizes these.
  • Diffing happens in plain JS, which is cheap compared to touching the DOM.
  • React uses heuristics: different element types → replace subtree; key props let it match list items efficiently (O(n) instead of O(n^3)).

Nuance: the VDOM isn't magically faster than hand-optimized vanilla DOM updates; its value is a declarative model with good-enough performance by default. Fiber (React 16+) adds interruptible, prioritized rendering so the UI stays responsive.

Keep renders fast: stable keys, React.memo, useMemo/useCallback, and avoiding unnecessary state in parents.

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium