当我注销用户时,
window.location.reload();
返回登录页面,但我想知道是否有更好的方法来处理此问题?
const handleLogout = () => {
logout();
window.location.reload();
};
答案 0 :(得分:0)
useHistory
钩子将完成此工作:
const history = useHistory()
history.push("/login")
此处示例https://codesandbox.io/s/elated-kare-op595?file=/src/Home.js