react route pass props using useHistory code example
Example 1: usehistory, uselocation
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>
);
}
Example 2: react router history push parameter
this.props.history.push({
pathname: '/template',
search: '?query=abc',
state: { detail: response.data }
})