Saved in this browser - sign in to keep your review list.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Keep going - a few more words and AI can grade it.
Interview lens
How interviewers actually use this question
Likely follow-ups
Is the Virtual DOM actually faster than updating the DOM by hand?Not by itself. Diffing adds work over a targeted manual write. The gain is fewer needless DOM writes while you keep declarative code.
If a component re-renders, does the real DOM always change?No. A re-render builds a new virtual tree. If the diff finds nothing, React skips DOM writes, but the render and diff work still ran.
How does React decide whether to update a node or replace it during diffing?A different element type replaces that subtree. The same type keeps the node and updates changed props. Keys match children in lists.
The Virtual DOM is an in-memory JavaScript copy of the DOM, and React keeps it in sync with the real DOM.
When state changes, React first builds a new virtual tree for the UI.
It diffs that new tree against the previous one and works out which changes the real DOM needs.
Then it applies only those changes to the real DOM, and React calls this whole process reconciliation.
The payoff is declarative code. I describe what the UI should look like, and React makes only the DOM writes it needs.
It isn't free, though. React still renders and diffs on every update, so a careful manual DOM write can beat it, and big trees may need React.memo or good keys.
Weak answers to avoid
Says the Virtual DOM is faster than the real DOMDiffing is extra work, so a targeted manual update can beat it. Say it avoids needless DOM writes while you keep declarative code.
Confuses the Virtual DOM with the shadow DOMShadow DOM is a browser feature that isolates a component's markup and styles. The Virtual DOM is React's in-memory tree. Mixing them up sounds memorized.
Defines it but never walks the diff stepsThe interviewer wants the mechanism. Walk it in order: build a new tree, diff it with the old one, work out the changes, apply only those to the real DOM.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.