mobx-react-router icon indicating copy to clipboard operation
mobx-react-router copied to clipboard

How to get route params?

Open alexeymakarov90 opened this issue 7 years ago • 4 comments

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

  • Except by parsing the location by own regexp

alexeymakarov90 avatar Jul 31 '18 12:07 alexeymakarov90

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.

alisd23 avatar Aug 17 '18 19:08 alisd23

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

damonmaria avatar Nov 08 '18 06:11 damonmaria

@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?

ikatun avatar Feb 19 '19 10:02 ikatun

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

damonmaria avatar Feb 25 '19 01:02 damonmaria