Analysis and summary of React diff algorithm

Source: Internet
Author: User
Tags diff

Original: https://zhuanlan.zhihu.com/p/20346379

Summarize what the individual understands after reading:

1, Tree diff: Only the same level of the node comparison, if the subtree in the new tree species does not exist, then directly deleted. If the new tree is created, what if a cross-hierarchical tree is moved? The answer is to delete the tree immediately before moving, creating an identical one after the move.

So try not to move across the hierarchy as much as possible in react.

2. Component diff: If it is the same component, continue comparing the virtual DOM tree. If not, delete the entire component directly and replace it with the same component

3. Element diff: There is a move, create and delete operation, this needless to say directly what meaning. Detailed algorithm details can be seen in the original, here do not delve into.

Analysis and summary of React diff algorithm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.