通过插槽的形式来复合组件
this.props.children 可以获取
{{ context:(
HomePage
),txt:“这是个文本”
}}
{{
content:“sdf”
}}
可以通过children.content获取到。
redux使用
数据存在store里面。
通过dispatch一个action提交对数据的更改。
action 提交到reducer函数,根据传入的action的type,返回新的state。
react-router
children >component > render
pureComponent 是什么?
纯组件
掌握使用,实现性能优化。
shouldComponentUpdate(nextProps,nextState){
return nextState.count !== this.state.count
}
如果不相等则不执行生命周期。
可以继承 extends PureComponent
内置了shouldComponentUpdate
缺点: pureComponent是浅比较。
pureComponent 可以提高性能,有的时候。