I am going through lot of articles over the internet asking the difference between the two, but almost everyone of them explains the difference between Virual DOM and Real DOM. According to my current knowledge, VirtualDOM is just a software concept where a separate copy of Real DOM is maintained…
Is ReactDOM just an implementation of the Virtual DOM ?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Yes, the Virtual DOM is a concept used in web development, and ReactDOM is a specific implementation of that concept in the context of React, which is a JavaScript library for building user interfaces.
Real DOM:
The Real DOM (Document Object Model) is a representation of the structure of a web page. It’s a hierarchical tree-like structure where each element on the web page is a node in the tree.
When there are changes to the state of a web page (due to user interaction or other events), the Real DOM updates, and the entire page might need to be re-rendered.
Virtual DOM:
The Virtual DOM is a programming concept. It involves creating a virtual representation of the Real DOM in memory.
Instead of directly manipulating the Real DOM every time a change occurs, React uses a Virtual DOM to perform the updates more efficiently.
When there’s a change in the application state, React first updates the Virtual DOM rather than the Real DOM.
(https://legacy.reactjs.org/docs/faq-internals.html)
ReactDOM:
ReactDOM is the specific implementation of React that is responsible for updating the Real DOM based on changes in the Virtual DOM.
ReactDOM takes care of efficiently updating only the parts of the Real DOM that have changed, rather than re-rendering the entire page.
It acts as a bridge between the virtual representation of the DOM that React works with and the actual DOM in the browser. (https://it.legacy.reactjs.org/docs/react-dom.html)
AFAI the ReactDom is an implementation of a VirtualDom. The VirtalDom is just a concept. The following is from this old react documentation: https://legacy.reactjs.org/docs/faq-internals.html
I hope this clears out some thinks