Flux Dispatch.dispatch(...):无法在分派中间进行分派 [英] Flux Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch

查看:89
本文介绍了Flux Dispatch.dispatch(...):无法在分派中间进行分派的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码 > https://gist.github.com/ButuzGOL/707d1605f63eef55e4af

因此,当我获得登录成功回调时,我想进行重定向,
重定向也可以通过调度程序进行.

So when I get sign-in success callback I want to make redirect,
redirect works through dispatcher too.

我正在获取Dispatch.dispatch(...):无法在调度中间进行调度.

And I am getting Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.

中间有什么技巧可以呼吁采取行动吗?

Is there any hack to call action in the middle ?

推荐答案

我看不到您发布的要旨中的什么地方在进行重定向.我只看到AUTH_SIGNIN和AUTH_SIGNIN_SUCCESS动作,它们看起来非常简单.

I don't see where in the gist that you posted you are doing the redirect. I only see the AUTH_SIGNIN and AUTH_SIGNIN_SUCCESS actions, and they look pretty straightforward.

但是,没有,在派遣过程中没有创建动作的技巧,这是设计使然.行动不应该是导致改变的事情.他们应该像报纸一样,将外部环境的变化通知应用程序,然后应用程序对该消息做出响应.商店本身会引起变化.行动只是告知他们.

But no, there is no hack to create an action in the middle of a dispatch, and this is by design. Actions are not supposed to be things that cause a change. They are supposed to be like a newspaper that informs the application of a change in the outside world, and then the application responds to that news. The stores cause changes in themselves. Actions just inform them.

如果遇到此错误,则需要备份并查看如何处理原始操作.通常,您可以将应用程序设置为响应原始操作,完成所需的所有操作,并避免尝试创建第二个操作.

If you have this error, then you need to back up and look at how you're handling the original action. Most often, you can set up your application to respond to the original action, accomplish everything you need to do, and avoid trying to create a second action.

这篇关于Flux Dispatch.dispatch(...):无法在分派中间进行分派的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆