How to react programmatically go to the page?

Study react, the master database now. For ranting and for learning the basics I read an article https://habrahabr.ru/post/329996/, all wound up, everything worked as it should, but the question arose - how do I open a page by clicking on the link (e.g. the timer) in the framework of the examples in this article? I tried to use 'history/createBrowserHistory' and there to do push in history, but the url changes but the page remains the same, the error console when this is coming down. Found examples where history is accessed through the props or context, but I neither there nor there in the component of trying to initiate the transition to the target page of history is missing.
June 7th 19 at 14:39
1 answer
June 7th 19 at 14:41
Solution
Wrap your component in withRouter HOC and you will be history in props.

import React { Component } from 'react';
import { withRouter } from "react-router-dom";


class componentName extends Component {

 componentDidMount() {
 setTimeout( () => this.props.history.push("your address"), 5000);
};

 render() {
 return (
the <div>

</div>
);
}
}

export default withRouter(componentName);
Super, earned. 've seen recommendations to use withRouter but without specifying how. - Orville_Hop commented on June 7th 19 at 14:44

Find more questions by tags React