Want to access history object in new React Router v4? Looks to me like you might be missing a withRouter connection. this would make the history props available to this component.
1 2 3 4 5 6 7 8 9 10 11 12 | import { withRouter } from 'react-router' class Home extends Component { functionMethod() { const { history: { push } } = this.props; doStuff(); push('/location'); } ... } export default withRouter(Home); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.