flux中Cannot dispatch in the middle of a dispatch问题的解决方案

在使用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);

这样就可以了,真心感觉老外很热心。


Previous
Hello World Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hex
2018-12-04 Pursue
Next
Hello JunZhou Hello JunZhou
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hex
2018-12-04 Pursue