useHistory做页面跳转导航

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

posted @   徐同保  阅读(1004)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示