How to access route parameters from a component other than the Router component

In React-router 1.0 / 2.0, you can access the routing parameters this.props.paramsfrom the Route component, but there seems to be no supported way to access the parameters from the component deep in the aforementioned Route component.

Access to the data can be obtained through context.location, but this raises a warning stating that it is out of date.

+4
source share
2 answers

Running in the latest version of React Router , all contextual data is outdated in favor this.context.router:

router. this.context.history, this.context.location this.context.route . , history (, push, replace) setRouteLeaveHook.

, location, ( ) .

+8

Source: https://habr.com/ru/post/1623596/


All Articles