The difference between href and link I understand.
But I want to know the difference between using the link and withrouter with history.push? If I have already accessed the page does history.push retrieve the page in the cache?
Using Link:
<Link className="btn btn-primary" onClick={logout} to="/">
Log out
</Link>
Using history:
constructor(props) {
super(props);
this.handleLogout = this.handleLogout.bind(this);
};
handleLogout(e) {
const { history } = this.props;
logout()
history.push("/");
}
<button type="button" onClick={this.handleLogout}>Log out</button>