- 使用PureCompoent是因为它是一个更具性能的Component的版本
- 性能的提高还伴随着一些附加的条件
- 提供了具有浅比较的shouldComponentUpdate方法
- 当props或者state改变时,PureComponent将对props和state进行浅比较
- Component的shouldComponentUpdate构造被调用默认重渲,PureCompoent不一定
- 不能再重写shouldComponentUpdate
- 不渲染的情况: 父组件中改变对象,子组件比较的是引用是否相同,改变数组、对象中的根键,不重新渲染
- 不要在render方法中创建一个新的函数,对象或者是数组,render只负责渲染
- 场景:组件收到的props和定义的state是基本类型时* 使用状态管理时 组件都可以用PureComponent