react-redux在子组件中访问store对象理解

1、connect理解

1.要在constructor-super里接收context对象

2. 给组件(class / pure function)指定contextType属性,用来接收store对象

以下代码模拟了connect(类似react-redux里connect的功能)高阶组件的实现:

2、在子组件使用

 

 

原文地址:https://www.cnblogs.com/surfer/p/11378963.html

扫码领红包

公众号

头条号