adspace
What is the difference between dom and virtual dom in reactjs?
Answer Posted / Madhumita Lalwani
{"DOM": "The Document Object Model (DOM) is a programming interface for HTML and XML documents. In React, when a component's state changes, the entire tree of components is re-rendered, causing the browser to update the DOM.nnExample: The browser updates the HTML by replacing the contents of <div id="root"> with a new version.",n"Virtual DOM": "The Virtual DOM is a lightweight JavaScript representation of the real DOM. React creates a virtual DOM and compares it with the previous one to determine the minimal set of changes needed to update the actual DOM. This results in faster rendering and better performance."
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers