0
点赞
收藏
分享

微信扫一扫

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


举报

相关推荐

0 条评论