Programmatically navigate using react router code example
Example 1: Programmatically navigate using react router
import { useHistory } from "react-router-dom";
function HomeButton() {
let history = useHistory();
function handleClick() {
history.push("/home");
}
return (
);
}
Example 2: navigating programatically react
import { Route } from 'react-router-dom'
const Button = () => (
(
)} />
)