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 Native #45

Open
TokenYangForever opened this issue Jun 12, 2018 · 0 comments
Open

React Native #45

TokenYangForever opened this issue Jun 12, 2018 · 0 comments

Comments

@TokenYangForever
Copy link
Owner

TokenYangForever commented Jun 12, 2018

fbjs

pureComponent

  • 一个组件前后接收相同的state和props,得到相同的渲染结果,那么就可以继承pureComponent。state/props是否相同,会通过fbjs/lib/shallowEqual函数来进行比较,这是一个浅比较的过程(所以应该只针对state/props比较简单且层级较低的情况,复杂结构就比较不出来了)。
  • 使用pureComponent时,如果组件的 props 和 state 都没发生改变, render 方法就不会触发,省去 Virtual DOM 的生成和比对过程,达到提升性能的目的。
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