![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
react
妍崽崽@
这个作者很懒,什么都没留下…
展开
-
react的Component和PureComponent
前言:react中的Component和PureComponent。Component和PureComponent的区别介绍React.PureComponent 与 React.Component 几乎完全相同,但 React.PureComponent 通过props和state的浅对比来实现 shouldComponentUpate()。在PureComponent中,如果包含比较复杂的数据结构,可能会因深层的数据不一致而产生错误的否定判断,导致界面得不到更新。如果定..原创 2020-09-22 14:09:37 · 518 阅读 · 1 评论 -
React.createContext
解决什么问题Context 通过组件树提供了一个传递数据的方法,从而避免了在每一个层级手动的传递 props 属性。何时使用 ContextContext 设计目的是为共享那些被认为对于一个组件树而言是“全局”的数据,例如当前认证的用户、主题或首选语言。例如,在下面的代码中,我们通过一个“theme”属性手动调整一个按钮组件的样式:function ThemedButton(props) { return <Button theme={props.theme} />;}转载 2020-09-22 13:58:41 · 3269 阅读 · 0 评论