2
votes

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.

1
Are you using react-router? is the url contstant so that you can map values to variables? i.e. /{type-of-clothes}/{color} ? - Mario Nikolaus

1 Answers

2
votes

You should try react-router react-router.by reacttraining. It solve almost every problem regarding routing.