1const currentURL = window.location.href // returns the absolute URL of a page
2
3const pathname = window.location.pathname //returns the current url minus the domain name
1import {withRouter} from 'react-router-dom';
2
3const SomeComponent = withRouter(props => <MyComponent {...props}/>);
4
5class MyComponent extends React.Component {
6 SomeMethod () {
7 const {pathname} = this.props.location;
8 }
9}