Reducers may not dispatch actions
来源:互联网 发布:java语言程序设计答案 编辑:程序博客网 时间:2024/05/20 23:38
今天在使用redux的时候出现一个bug
Reducers may not dispatch actions
情景如下
onOk={() => { this.props.changeSubmitModalState(); this.props.postOrderCombine(this.props.carOrders, ((time) => { const hide = message.loading('提交订单中, 请等待...', 0); return () => { hide(); message.success('提交订单成功!', time); console.log('clear'); this.props.emptyOrder(); }; })(2));
查查文档
A Note for Flux Users
If you attempt to call dispatch
from inside the reducer, it will throw with an error saying “Reducers may not dispatch actions.” This is similar to “Cannot dispatch in a middle of dispatch” error in Flux, but doesn't cause the problems associated with it. In Flux, a dispatch is forbidden while Stores are handling the action and emitting updates. This is unfortunate because it makes it impossible to dispatch actions from component lifecycle hooks or other benign places.
In Redux, subscriptions are called after the root reducer has returned the new state, so you may dispatch in the subscription listeners. You are only disallowed to dispatch inside the reducers because they must have no side effects. If you want to cause a side effect in response to an action, the right place to do this is in the potentially async action creator.
所以在reducer中是不允许disp一个action的(使得redux保持pure)
- Reducers may not dispatch actions
- Could not dispatch event
- Could not dispatch event
- may not respond to
- interface may not exist
- GetThreadCallStack may not work
- Dispatch时产生了这个异常:does not contain handler parameter named ‘method’ This may be caused by whitespace in the label text
- actions
- Actions
- Actions
- Actions
- Actions
- Actions
- Redux中的Reducers
- dispatch
- dispatch
- RFC 中的MUST,MUST NOT,SHOULD,SHOULD NOT,MAY,MAY NOT 解释
- TempData may not works under distributed system
- 《systemverilog验证》阅读笔记 -- 过程语句和子程序
- PIC单片机入门_PICC的指向RAM的指针
- 构建高并发高可用的电商平台架构实践
- 硬件设计の运算放大器の一
- POJ 3169 Layout 差分约束系统
- Reducers may not dispatch actions
- 基础练习 特殊回文数
- 玲珑oj 1046- chess play【水】
- Linux文件与目录管理
- 解决redhat linux乱码的问题
- Android状态栏着色工具类
- 累啊
- 基础练习 回文数
- 编码中的setCharacterEncoding 理解,中文乱码的问题