How to get current route in react-router 2.0.0-rc5
If you use the history,then Router put everything into the location from the history,such as:
this.props.location.pathname;
this.props.location.query;
get it?
After reading some more document, I found the solution:
https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/location.md
I just need to access the injected property location
of the instance of the component like:
var currentLocation = this.props.location.pathname
You can get the current route using
const currentRoute = this.props.routes[this.props.routes.length - 1];
...which gives you access to the props from the lowest-level active <Route ...>
component.
Given...
<Route path="childpath" component={ChildComponent} />
currentRoute.path
returns 'childpath'
and currentRoute.component
returns function _class() { ... }
.