Skip to content

Commit ed21298

Browse files
shubhu121juliusmarminge
authored andcommitted
fix(mobile): prevent crash on sign out in settings
1 parent 2cb1a26 commit ed21298

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎apps/mobile/src/features/settings/SettingsAuthRouteScreen.tsx‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useAuth } from "@clerk/expo";
22
import { AuthView, UserProfileView } from "@clerk/expo/native";
33
import { StackActions, useNavigation } from "@react-navigation/native";
4-
import { useCallback, useLayoutEffect } from "react";
4+
import { useCallback, useEffect, useLayoutEffect, useRef } from "react";
55
import { View } from "react-native";
66

77
import { hasCloudPublicConfig } from "../cloud/publicConfig";
@@ -25,11 +25,21 @@ function ConfiguredSettingsAuthRouteScreen() {
2525
() => navigation.dispatch(StackActions.popTo("SettingsContent")),
2626
[navigation],
2727
);
28+
const hasBeenSignedIn = useRef(isSignedIn);
29+
if (isSignedIn) {
30+
hasBeenSignedIn.current = true;
31+
}
32+
33+
useEffect(() => {
34+
if (hasBeenSignedIn.current && isLoaded && isSignedIn === false) {
35+
navigation.dispatch(StackActions.popTo("SettingsContent"));
36+
}
37+
}, [isLoaded, isSignedIn, navigation]);
2838

2939
return (
3040
<View collapsable={false} className="flex-1 overflow-hidden bg-sheet">
3141
{isLoaded ? (
32-
isSignedIn ? (
42+
hasBeenSignedIn.current ? (
3343
<UserProfileView isDismissible={false} onHostBack={handleHostBack} />
3444
) : (
3545
<AuthView isDismissible={false} onHostBack={handleHostBack} />

0 commit comments

Comments
 (0)