useHistory

The useHistory hook gives you access to the history instance that you may use to navigate.



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>
  );
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2021-05-19
  • 2022-01-07
  • 2021-05-06
猜你喜欢
  • 2021-10-01
  • 2021-07-12
  • 2021-10-21
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-04-05
相关资源
相似解决方案