Question · JavaScript and React course · Module 1: React Basics

Diffing algorithm in Virtual DOM

What does the diffing (reconciliation) algorithm in React do?

Answer options

  • It converts HTML to XML for faster processing by the browser
  • It removes the entire real DOM and rebuilds it from scratch on every state change
  • It creates a backup of the page before each interface change
  • It compares the new Virtual DOM tree with the previous one and calculates the minimal changes to apply to the real DOM
Show the answer

Correct answer:

  • It compares the new Virtual DOM tree with the previous one and calculates the minimal changes to apply to the real DOM