Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.67k stars 777 forks source link

This virtual-dom algorithm is used in facebook react Native? #424

Open rogerjiang opened 7 years ago

rogerjiang commented 7 years ago

Is this virtual-dom algorithm used in reactNative. I don't know what is the different between the react Native. Thank you very much.

arun2786 commented 7 years ago

React creates a new object of DOM tree (VirtualDOM tree) and manipulates it thus increases performance. To port this new DOM structure to various platforms we do need something that maps to the View components existing in Android and iOS, which is like reimplement a subset of a real DOM based on mobile technology. Dont know what kind of replacement is used by react-native but WEEX is one of the solutions.

React used VirtualDOM that is a form of IR (Intermediate Representation)

IR: An intermediate representation is a representation of a program part way between the source and target languages. A good IR is one that is fairly independent of the source and target languages, so that it maximizes its ability to be used in a re-targetable compiler.

  1. Original code is spitted out to Intermediate Representation (IR) code.
  2. Then optimiser, mangling one IR into optimised equivalent IR (android, ios).
  3. Then, machine code is produced by this IR optimised for a specific CPU (x86, arm, etc...)