I have a pretty simple set of react components:
container
that hooks into redux and handles the actions, store subscriptions, etclist
which displays a list of my itemsnew
which is a form to add a new item to the list
I have some react-router routes as follows:
<Route name='products' path='products' handler={ProductsContainer}>
<Route name='productNew' path='new' handler={ProductNew} />
<DefaultRoute handler={ProductsList} />
</Route>
so that either the list
or the form
are shown but not both.
What I'd like to do is to have the application re-route back to the list once a new item has been successfully added.
My solution so far is to have a .then()
after the async dispatch
:
dispatch(actions.addProduct(product)
.then(this.transitionTo('products'))
)
Is this the correct way to do this or should I fire another action somehow to trigger the route change?
redux-react-router
and this will require a large refactor so may have to wait. If I come up with a solution in the meantime I'll post an answer