Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

说一下 React diff 算法 #222

Open
lgwebdream opened this issue Jul 6, 2020 · 2 comments
Open

说一下 React diff 算法 #222

lgwebdream opened this issue Jul 6, 2020 · 2 comments
Labels
React teach_tag 脉脉 company

Comments

@lgwebdream
Copy link
Owner

No description provided.

@lgwebdream lgwebdream added React teach_tag 脉脉 company labels Jul 6, 2020
@lgwebdream
Copy link
Owner Author

扫描下方二维码,获取答案以及详细解析,同时可解锁800+道前端面试题。

@gujiwuqing
Copy link

在react中,使用虚拟dom替代真实dom,而diff算法则是实现最小化页面重绘的体现。在diff算法中有三大策略,分别是树策略(tree diff),组件策略(component diff)以及元素策略(element diff)。

策略一(tree diff): Web UI中DOM节点跨层级的移动操作特别少,可以忽略不计。

策略二(component diff): 拥有相同类的两个组件 生成相似的树形结构, 拥有不同类的两个组件 生成不同的树形结构。

策略三(element diff): 对于同一层级的一组子节点,通过唯一id区分。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React teach_tag 脉脉 company
Projects
None yet
Development

No branches or pull requests

2 participants