× 类型错误: 无法读取未定义的属性'history'



已登录用户,但重定向不起作用。如何解决这些问题?这是

登录组件代码:

const Login = ({ props }) => {
const [email, setEmail] = useState();
const [password, setPassword] = useState();
const alert = useAlert();
const dispatch = useDispatch();
const { isAuthenticated, error, loading } = useSelector(
(state) => state.auth
);
useEffect(() => {
if (isAuthenticated) {
props.history.push("/");
}
if (error) {
alert.error(error);
dispatch(clearErrors());
}
}, [dispatch, alert, error, loading, props, isAuthenticated]);
const submitHandler = (e) => {
e.preventDefault();
dispatch(login(email, password));
};  
return ()
}

错误:

TypeError: Cannot read property 'history' of undefined

您从道具中销毁道具吗?也许你的意思是({ history, aProp, bProp })

最新更新