Answers for "how to programatically redirect with react router"

2

programmatically redirect react router

import { useHistory } from "react-router-dom";

function HomeButton() {
  const history = useHistory();

  function handleClick() {
    history.push("/home");
  }

  return (
    <button type="button" onClick={handleClick}>
      Go home
    </button>
  );
}
Posted by: Guest on February-15-2020

Code answers related to "how to programatically redirect with react router"

Code answers related to "Javascript"

Browse Popular Code Answers by Language