Answers for "onclick redirect to another page react js <Redirect /> not"

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 "onclick redirect to another page react js <Redirect /> not"

Code answers related to "Javascript"

Browse Popular Code Answers by Language