What is the virtual DOM, and how does React use it?

React basics · Freshers

Model answer

The virtual DOM is a lightweight JavaScript description of the interface that React keeps in memory. When state changes, React builds a new description, compares it with the previous one (called reconciliation or diffing), and applies only the differences to the real DOM.

The point is not that it is magically fast, but that you write code as "this is the UI for this state" and React works out the smallest set of real changes.

Learn this topic

What Is React? Why Use It and How It Works in the course React.js Full Course: Beginner to Advanced.

Sign in to add your own answer.

More questions