随笔分类 -  redux

摘要:1. 要在constructor-super里接收context对象 2. 给组件(class / pure function)指定contextType属性,用来接收store对象 以下代码模拟了connect(类似react-redux里connect的功能)高阶组件的实现: 阅读全文
posted @ 2019-08-19 18:58 sophel 阅读(2288) 评论(0) 推荐(0) 编辑
摘要:在使用了combineReducers的场景下,要注意reducers里的state初始化处理,否则到combineReducers函数过程中会抛出异常,原因是combineReducers内部进行了每个reducer断言。 跟踪源码可知原理如下: 继续debug,进入assertReducerSh 阅读全文
posted @ 2019-07-23 15:10 sophel 阅读(2549) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示