Answers for "how to redirect in react after button"

6

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;
Posted by: Guest on December-16-2020

Code answers related to "how to redirect in react after button"

Code answers related to "Javascript"

Browse Popular Code Answers by Language