How's Virtual DOM implementation is different than createDocumentFragment() if no state is observed?

前端 未结 2 1177
盖世英雄少女心
盖世英雄少女心 2021-02-08 05:11

Virtual DOM is a light weight copy of DOM, maintained / cached locally before inserting it into actual DOM. We can change it as we want and then save to our real DOM tree. It us

2条回答
  •  借酒劲吻你
    2021-02-08 05:23

    Virtual DOM is a virtual representation of the UI tree. Its name is misleading as it's not linked to the DOM any more. Nowadays React can be used for web apps with react-dom or for mobile apps with react-native.

    It's true that DocumentFragment and Virtual DOM are similar: tree like structures containing nodes with similar information. One could indeed use DocumentFragment to track changes and update the DOM when necessary. However it wouldn't be possible to use it on native development. Also the nodes will contain unnecessary properties and methods.

提交回复
热议问题