Get the current path in a react component [duplicate] Get the current path in a react component [duplicate] reactjs reactjs

Get the current path in a react component [duplicate]


Add your component to router first

<Router path="/" component={Navigation}  />

You can get your path in

this.props.location.pathname

This is a readme for location

https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/location.md