button onclick redirect to another component react code example
Example: redirect onclick react
import React from 'react';
import { useHistory } from "react-router-dom";
function Home() {
const history = useHistory();
const handleRoute = () =>{
history.push("/about");
}
return (
<Button
onClick={handleRoute}>
About
</Button>
);
}
export default Home;