In React-router 1.0/2.0 one can access routing params as this.props.params
from a Route component - but there seems no supported way to access params from a component deeply contained in the above Route component.
The data sort of could be accessed through context.location
but this one throws a warning, stating this is deprecated.
Starting in the latest version of React Router, all the context data has been deprecated in favor of this.context.router
:
Only an object named
router
is added to context. Accessingthis.context.history
,this.context.location
, andthis.context.route
are all deprecated. This new object contains the methods available fromhistory
(such aspush
,replace
) along withsetRouteLeaveHook
.
Unfortunately, this doesn't include the location
data, so you'll need to pass it yourself into child (non-route handler) components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With