What is the virtual DOM in React and why does React use it?
Updated Apr 23, 2026
Short answer
The virtual DOM is a lightweight in-memory tree of React elements. React compares it to the previous tree (reconciliation) to compute minimal updates to the real DOM, which avoids expensive full-page reflows for most UI changes.
Deep explanation
When state or props change, React creates a new element tree. The reconciler walks old vs new trees, keys children where possible, and produces a set of DOM operations. This batching and diffing is what people mean by “virtual DOM” in practice—not a second browser DOM, but React’s representation used for efficient patching.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro