What is virtual Dom in React Js



Before Knowing about Virtual DOM, lets first discuss about DOM. DOM is document object model which is in the structure of  tree.
Every html page we write will be converted into DOM internally which looks something like below



What comes next in the page will be clearly been set on the DOM once an HTML page is created.When there is any change in the page, the whole DOM gets manipulated in order to update the changes in the page.
now,

What is virtual DOM.

React would create an exact copy of the DOM which is already been created which is the virtual DOM. Whenever there are any changes in the DOM , react checks whether both the DOM are being matched.

Now the copy of the actual DOM is not matching with the actual DOM. The mismatched part will only be updated instead of updating the whole DOM. Thus react helps us in solving the expensive DOM manipulation problem by using the concept of virtual DOM.

Share this

Related Posts

Previous
Next Post »