mapStateToProps在构造函数之前没有被神奇地调用。它是通过connect完成的,connect是在组件初始化之前执行的高阶组件
mapStateToProps。实际上,会
connect初始化您体内的组件。
connect(mapStateToProps, mapDispatchToProps)(YourComponent)
为什么
componentWillReceiveProps不执行?因为React不要求
componentWillReceiveProps初始渲染,所以应该使用它
componentDidMount。
componentWillReceiveProps
组件接收新道具时调用。初始渲染不调用此方法。



