Interview Questions · ReactJs ReactJs
Why does React use a Virtual DOM instead of directly manipulating the real DOM on every update?
Practice question from Interview Questions (ReactJs ReactJs), with the correct answer and a step-by-step solution.
easy · MCQ · Q-1CA205
Why does React use a Virtual DOM instead of directly manipulating the real DOM on every update?
- A.Because the real DOM cannot be updated programmatically at all
- B.To batch and minimize expensive real DOM operations by diffing lightweight in-memory trees firstCorrect answer
- C.Because browsers do not allow JavaScript to read the DOM
- D.To permanently replace the real DOM so the browser never renders HTML
Solution
Direct, unbatched DOM manipulation is slow because layout and paint can be triggered on every change; consider how diffing before touching the DOM helps.
More from Interview Questions
- What is a Higher-Order Component (HOC) in React?
- In a function component, which useEffect dependency-array configuration most closely mirrors the behavior of componentDidMount from class c…
- What problem does the React Context API primarily solve?
- What distinguishes a controlled component from an uncontrolled component in React forms?
Practise more ReactJs
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed