17 | super(props); 18 | 19 | this.state = { > 20 | location: props.history.location | ^ 21 | }; 22 | 23 | // This is a bit of a hack. We have to start listening for location code example
Example: react router dom push
import { useHistory } from "react-router-dom";
function HomeButton() {
let history = useHistory();
function handleClick() {
history.push("/home");
}
return (
<Button type="button" onClick={handleClick}>
Go home
</Button>
);
}