1

Pascal Precht wrote a great article on change detection in Angular. While I understand that zone.js and virtual DOM are completely different concepts, is zone.js for Angular the equivalent of virtual DOM for React? If yes, what are the main differences, if no please briefly explain why.

Kostas Siabanis
  • 2,989
  • 2
  • 20
  • 22
  • `zone.js` is basically monkey patch almost all possible async/events, and run change detection once those events completed. Eventually it helps Angular binding upto date on UI. Whereas Virtual DOM is completely different, it is used by react to render DOM on DOM tree with optimized way(internally it uses DOM Diffing algo to make it faster). – Pankaj Parkar Aug 13 '17 at 07:01
  • Thanks for answering. Please consider posting this as an answer so I can accept it and help future readers that perhaps have the same question. – Kostas Siabanis Aug 15 '17 at 16:06

1 Answers1

5

zone.js It basically monkey patches async/events like

  1. Timer
  2. Events
  3. Network Call and run change detection once those events executed. Eventually it helps to binding in sync on HTML.

Whereas Virtual DOM is completely different, it is used by react to render DOM on DOM tree with optimized way. Internally react uses DOM Diffing / React Reconciliation algorithm to make it faster by having multiple copies of DOM.

Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299