我有一个支付功能,这是一个按钮,点击调用,如果用户没有登录,我想重定向该用户到签署组件。这是我的函数代码。
const PaymentMethod = ()=>{
if(!isAuthenticated())
{
toast.error('Please signin to continue');
history.push('/signin') //works properly
// return <Redirect to = '/signin' /> // not working properly
}
}
// isAuthenticated is a boolean function that look whether the user is signed in or not 发布于 2022-10-01 16:36:34
试一试
return <Redirect to = '/signin' /> 因为您必须呈现Redirect才能产生效果
https://stackoverflow.com/questions/73920030
复制相似问题