ReactQuestion 01 of 28
What is virtual DOM? How does it actually work?
Answer out loud or in your head first, then compare.
Answer
React describes the UI as a structure in memory.
When state or props change, the component is logically rendered again, and during reconciliation React works out which changes to apply to the real DOM.
JSX
function Counter() {
const [count, setCount] =
useState(0);
return <h1>{count}</h1>;
}After:
JavaScript
setCount(1);React doesn't have to build the whole page again. It updates what actually changed.
To be precise:
Don't say “the Virtual DOM is always faster than the DOM”. The main benefit is the declarative UI model and managed updates.
How did it go? Be honest — “Not yet” puts the question on your review list.