fix: guest login not work sometimes

This commit is contained in:
Tristan Yang
2023-07-27 22:46:12 +08:00
parent 5a0842273b
commit 8d293abd1d
2 changed files with 14 additions and 18 deletions
+4 -2
View File
@@ -11,10 +11,12 @@ const GuestLogin = () => {
const [guestLogin] = useLazyGuestLoginQuery();
const { token, guest } = useAppSelector((store) => store.authData);
useEffect(() => {
if (!guest) {
if (!guest || !token) {
guestLogin();
}
}, [guest]);
}, [guest, token]);
console.log("guest", token, guest);
if (token && guest) return <Navigate to={"/"} replace />;
return null;
};