fix(mobile): prevent crash on sign out in settings (#4899)
This commit is contained in:
1 parent
07e668dc48
commit
277a7cb445
1 file changed
+12
-2
@@ -1,7 +1,7 @@
|
||||
import { useAuth } from "@clerk/expo";
|
||||
import { AuthView, UserProfileView } from "@clerk/expo/native";
|
||||
import { StackActions, useNavigation } from "@react-navigation/native";
|
||||
import { useCallback, useLayoutEffect } from "react";
|
||||
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { View } from "react-native";
|
||||
|
||||
import { hasCloudPublicConfig } from "../cloud/publicConfig";
|
||||
@@ -25,11 +25,21 @@ function ConfiguredSettingsAuthRouteScreen() {
|
||||
() => navigation.dispatch(StackActions.popTo("SettingsContent")),
|
||||
[navigation],
|
||||
);
|
||||
const hasBeenSignedIn = useRef(isSignedIn);
|
||||
if (isSignedIn) {
|
||||
hasBeenSignedIn.current = true;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (hasBeenSignedIn.current && isLoaded && isSignedIn === false) {
|
||||
navigation.dispatch(StackActions.popTo("SettingsContent"));
|
||||
}
|
||||
}, [isLoaded, isSignedIn, navigation]);
|
||||
|
||||
return (
|
||||
<View collapsable={false} className="flex-1 overflow-hidden bg-sheet">
|
||||
{isLoaded ? (
|
||||
isSignedIn ? (
|
||||
hasBeenSignedIn.current ? (
|
||||
<UserProfileView isDismissible={false} onHostBack={handleHostBack} />
|
||||
) : (
|
||||
<AuthView isDismissible={false} onHostBack={handleHostBack} />
|
||||
|
||||
Reference in new issue
Block a user