Open History to see the last commit
1import { useAuth } from "@clerk/expo";
2import { AuthView, UserProfileView } from "@clerk/expo/native";
3import { StackActions, useNavigation } from "@react-navigation/native";
4import { useCallback, useLayoutEffect } from "react";
5import { View } from "react-native";
6
7import { hasCloudPublicConfig } from "../cloud/publicConfig";
8
9export function SettingsAuthRouteScreen() {
10 const navigation = useNavigation();
11
12 useLayoutEffect(() => {
13 if (!hasCloudPublicConfig()) {
14 navigation.dispatch(StackActions.replace("SettingsContent"));
15 }
16 }, [navigation]);
17
18 return hasCloudPublicConfig() ? <ConfiguredSettingsAuthRouteScreen /> : null;
19}
20
21function ConfiguredSettingsAuthRouteScreen() {
22 const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
23 const navigation = useNavigation();
24 const handleHostBack = useCallback(
25 () => navigation.dispatch(StackActions.popTo("SettingsContent")),
26 [navigation],
27 );
28
29 return (
30 <View collapsable={false} className="flex-1 overflow-hidden bg-sheet">
31 {isLoaded ? (
32 isSignedIn ? (
33 <UserProfileView isDismissible={false} onHostBack={handleHostBack} />
34 ) : (
35 <AuthView isDismissible={false} onHostBack={handleHostBack} />
36 )
37 ) : null}
38 </View>
39 );
40}