Reputation: 1415
For example if I would like the url to automatically change to /jeans/black whenever state.filters == {type: jeans, color: black}
The only way I know how to do it would be to do window.location = someNewLocation every time a click happens, and make up a url based on state.
But I feel like there must be some in built way to do this? it's my first react redux project so I don't really know the best practices.
I've tried with routers but it only works when you go to that url directly. It doesn't update the url when state changes happen.
Would a subscribe on the filter state and window.location be the solution? I thought that with connect from react-redux subscribes were no longer necessary.
Upvotes: 2
Views: 537
Reputation: 780
You should try react-router react-router.by reacttraining. It solve almost every problem regarding routing.
Upvotes: 1