IBM / mobx-react-router

Keep your MobX state in sync with react-router
MIT License
439 stars 48 forks source link

How to get route params? #54

Open alexeymakarov90 opened 6 years ago

alexeymakarov90 commented 6 years ago

If we use @withRouter we will receive "match" in props. How can we get match.params from routingStore ?

alisd23 commented 6 years ago

There's currently no support for url match params in the store. Because of the fact you can use the same param names multiple times in an app, at different levels, there could be conflicts with the names.

I know that react-router-redux and connected-react-router also don't support this. You'll just have to access the match params through your Router/Match components.

damonmaria commented 5 years ago

FYI you can call matchPath which will get the match for you from a given path.

ikatun commented 5 years ago

@damonmaria is there a way to extract the currently active path (or a list of paths) from the router which I could give as a path argument to matchPath?

damonmaria commented 5 years ago

@ikatun location.pathname in the RouterStore has the current path.