NOTE Haven't tested with more complex transitions, so I'm sure there's some things missing. Just works for what I currently need. May decide this is a bad idea in the morning...
Stick <Redirector />
somewhere in your state tree where it'll always be rendered (e.g. in a Container component).
Add the redirectorReducer
reducer to your reducers as redirector
, e.g.
import { routerStateReducer as router } from 'redux-react-router'
import { redirectorReducer as redirector } from './Redirector'
const reducers = combineReducers({
router,
redirector,
// etc...
})
Then where you need to transition, use transitionNext
:
import { transitionNext } from '../../Redirector'
const formSubmittedAction = result => dispatch => ({
// do stuff..
dispatch(transitionNext(`/items/${result.id}`))
})