Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pushState works in ComponentWillReceiveProps. But doesn't work when I directly dispatch is as part of an action. #243

Closed
xinghengwang opened this issue Mar 7, 2016 · 3 comments

Comments

@xinghengwang
Copy link

I want to using pushState to redirect user after he does something.
function someAction () { return dispatch => { dispatch(someOtherAction); //this modifies the state. dispatch(pushState('newroute'); } }
but the dispatch pushState doesn't seems to work. However, in ComponentWillReceiveProps (I do a pushState, it works.)
Any thoughts on why this is the case?

@mjrussell
Copy link
Contributor

@xinghengwang what does your create store look like? One thing I could think of is that because you are using redux-thunk the order of the store enhancer with the middleware could cause the action not to get picked up. I'd be interested to know if you see the dispatched action in redux-logger when you use the action creator

@xinghengwang
Copy link
Author

I am using this template:
https://github.com/erikras/react-redux-universal-hot-example
I forked it a while ago (when it was still on redux router, even though latest version has updated to redux-react-router), but createStore is pretty much the same:

https://github.com/erikras/react-redux-universal-hot-example/blob/ad0c0ad6d69013b7ac9bf1454dfaef0381873188/src/redux/create.js

@mjrussell
Copy link
Contributor

I think this is a duplicate of #191. Can you try some of the advice in #191 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants