/
/foo
/foo/3
<app></app>
in componentDidMount which is performed a certain action. When I go to url on (/foo, /foo/3) then be loaded on other components, but the action component of the App no longer works, that is logical.import React { Component } from 'react';
import { withRouter } from 'react-router-dom';
import { someAcion } from '../somePlace';
class App extends Component {
...
componentWillReciveProps(nextProps) {
if (this.props.location !== nextProps.location) {
this.props.someAciton();
}
}
...
}
const mapDispatchToProps = {
someAction,
};
export default withRouter(connect(null, mapDispatchToProps)(App));
Find more questions by tags React