Avoid updating auth state on error
This commit is contained in:
parent
b9e4b15962
commit
cc1ccf860d
@ -55,10 +55,12 @@ export default function AppStateProvider({
|
||||
|
||||
const invalidateSwr = useCallback(() => setSwrTimestamp(Date.now()), []);
|
||||
|
||||
const { data } = useSWR('getAuth', getAuthAction);
|
||||
const { data, error } = useSWR('getAuth', getAuthAction);
|
||||
useEffect(() => {
|
||||
setUserEmail(data?.user?.email ?? undefined);
|
||||
}, [data]);
|
||||
if (!error) {
|
||||
setUserEmail(data?.user?.email ?? undefined);
|
||||
}
|
||||
}, [data, error]);
|
||||
const isUserSignedIn = Boolean(userEmail);
|
||||
useEffect(() => {
|
||||
if (isUserSignedIn) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user