本文介绍了React-Router推送回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在react-router推送后触发一个同步动作,这似乎是异步的
I need to trigger a synchronous action after react-router push, which appears to be async
是否可以做类似的事情:
Is it possible to do something like:
dispatch(push('/', callbackFunction))
在react-router文档中我没有看到有关push
回调的任何信息,这似乎很奇怪...
I don't see anything in the react-router docs about a callback to push
, which seems quite odd...
推荐答案
看来,push
不是异步的,因为它只是一个动作创建者(工厂模式).
As it seems, push
is not asynchronous since it is just an action creator (factory pattern).
因此您可以触发以下操作:
So you could trigger you actions like this:
dispatch(push('/'));
dispatch(otherAction());
这篇关于React-Router推送回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!