react get path code example
Example 1: react current path
//Add your component to router
<Router path="/" component={Navigation} />
//Get your path
this.props.location.pathname
Example 2: get current url react router
import {withRouter} from 'react-router-dom';
const SomeComponent = withRouter(props => <MyComponent {...props}/>);
class MyComponent extends React.Component {
SomeMethod () {
const {pathname} = this.props.location;
}
}