angularreactjsvirtual-domzone.js

Is zone.js for Angular, what is the virtual DOM for React?


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.


Solution

  • 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.