How to listen to route changes in react router v4?

I use withRouter to get the location prop. When the component is updated because of a new route, I check if the value changed: @withRouter class App extends React.Component { static propTypes = { location: React.PropTypes.object.isRequired } // … componentDidUpdate(prevProps) { if (this.props.location !== prevProps.location) { this.onRouteChanged(); } } onRouteChanged() { console.log(“ROUTE CHANGED”); } // … Read more