Virtual DOMReconciliationDiffing AlgorithmReact InternalsKeys

Reconciliation & Virtual DOM

Understand how React efficiently updates the UI using the Virtual DOM and reconciliation. Master the diffing algorithm, the role of keys, and the internal process that makes React fast — essential knowledge for frontend interviews.

35 min read14 sections
01

Overview

React doesn't update the real DOM directly when state changes. Instead, it maintains a lightweight JavaScript representation of the UI called the Virtual DOM. When something changes, React creates a new Virtual DOM tree, compares it with the previous one, and calculates the minimal set of changes needed — a process called reconciliation.

The diffing algorithm at the heart of reconciliation uses clever heuristics to compare trees in O(n) time instead of the theoretical O(n³). This is what makes React feel fast — it batches and minimizes real DOM operations, which are the most expensive part of any UI update.

Understanding this process is critical for writing performant React apps and answering one of the most frequently asked frontend system design interview topics.

Why this matters

Interviewers expect you to explain how React updates the UI internally. Knowing reconciliation helps you understand why keys matter, why unnecessary re-renders are expensive, and how to optimize component trees.

1 / 14