Answers for "how to navigate to a url programmatically in react router"

0

Programmatically navigate using react router

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

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

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

  return (
    <button type="button" onClick={handleClick}>
      Go home
    </button>
  );
}
Posted by: Guest on November-28-2019

Code answers related to "how to navigate to a url programmatically in react router"

Code answers related to "Javascript"

Browse Popular Code Answers by Language