Common React Interview Questions Flashcards
What is the difference between the Virtual DOM and the real DOM?
The DOM is a tree representation of the HTML and CSS document that you wrote. When you use the DOM API with vanilla JS or the like, any change to the DOM requires a full reload of the DOM, which can be really inefficient.<div><br></br></div><div>Think of a table with 10,000 rows where one row changes.</div><div><br></br></div><div>The virtual DOM is a concept older than React and used other places as well, but it just consists of React building virtual representations of the DOM with each change, and then comparing a diff of the two. When it detects a change in state, because it is using that diff, it can rerender just the effected node and its children, instead of every node.</div>