React-router push callback?

眉间皱痕 提交于 2019-12-10 16:23:51

问题


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))

I don't see anything in the react-router docs about a callback to push, which seems quite odd...


回答1:


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());

Relevant lines



来源:https://stackoverflow.com/questions/41762677/react-router-push-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!