Add authLoading guard to Profile page
This commit is contained in:
@@ -21,6 +21,7 @@ function formatTime(seconds: number) {
|
||||
|
||||
export default function Profile() {
|
||||
const user = useAuthStore((s) => s.user);
|
||||
const authLoading = useAuthStore((s) => s.isLoading);
|
||||
const logout = useAuthStore((s) => s.logout);
|
||||
const loadUser = useAuthStore((s) => s.loadUser);
|
||||
const navigate = useNavigate();
|
||||
@@ -39,6 +40,7 @@ export default function Profile() {
|
||||
const [passwordSuccess, setPasswordSuccess] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
if (authLoading) return;
|
||||
if (!user) {
|
||||
navigate('/login');
|
||||
return;
|
||||
@@ -52,7 +54,7 @@ export default function Profile() {
|
||||
if (h) setGameHistory(h.data);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, [user, navigate]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [user, authLoading, navigate]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
if (!user || loading) return;
|
||||
|
||||
Reference in New Issue
Block a user