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 setState时需要注意的优化】 #61

Open
kind-hearted opened this issue Oct 9, 2018 · 0 comments
Open

【React setState时需要注意的优化】 #61

kind-hearted opened this issue Oct 9, 2018 · 0 comments

Comments

@kind-hearted
Copy link
Owner

kind-hearted commented Oct 9, 2018

state = {
  text: 'hello'
}

setState({
  text: 'hello'
})

上述代码在没有经过任何优化时(shouldUpdateComponent),依然会执行一次完整的虚拟dom渲染和diff,对脚本性能有影响。在React中只要调用setState就会从组件自身开始去渲染其后代所有子组件并进行diff。React将性能优化都交给用户自己做。

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

No branches or pull requests

1 participant