您的位置:首页 > 其它

Flux Dispatch.dispatch(…): Cannot dispatch in the middle of a dispatch

2018-03-03 10:22 513 查看
在使用flux进行数据交互的时候,出现了一个问题
Flux Dispatch.dispatch(…): Cannot dispatch in the middle of a dispatch
,在国内竟然没有找到解决方案,最后在https://stackoverflow.com上找到了解决方案,但是原理不清楚【这不是我的风格,空下来一定搞懂】。

解决方案:

老外是这么说的:

You can make it work by “scheduling” the next action instead of calling it directly, here is an example code:

译:你可以在指定的时间调度一个action而不是直接调用它。

// instead of doing this
Dispatcher.dispatch(...);

// go like this
setTimeout(function() {
Dispatcher.dispatch(...);
}, 1);


我的解决方案:

setTimeout(function () {
Actions.synchronizePanekeyToStore(currenPaneKey);
}, 1);


这样就可以了,真心感觉老外很热心。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐