redux-router: Problem with dispatching pushState(...) using redux-thunk
I use redux-thunk
which offers dispatch
and getState
in the action creator.
loginSuccess
is a redux duck function which dispatches two actions, the second of which is pushState
that is supposed to redirect to the attempted path after successful login.
export function loginSuccess(result) {
return (dispatch, getState) => {
dispatch({type: LOGIN_SUCCESS, result});
const router = getState().router;
dispatch(pushState(null, router.location.query.redirect))
};
}
I can see an action of type @@reduxReactRouter/historyAPI
is dispatched with this payload:
{"method": "pushState", "args": [null, "/path"]}
And nothing happens in the history!
However, when I dispatch the action creator in a component the route changes successfully and a @@reduxReactRouter/routeDidChange
action is dispatched and everything is fine.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (1 by maintainers)
@mohebifar This is the modified create.js
I also removed
redux-thunk
, and in clientMiddleware.js I did this:Added the client as a third parameter of the actions passed as a function… to be used like this in the action creator. eg. redux/modules/auth.js
Cheers
@timaschew figured out… actually the issue was in the ordering of the middleware. thanks anyway