import { useAuth } from "@clerk/expo"; import { AuthView, UserProfileView } from "@clerk/expo/native"; import { StackActions, useNavigation } from "@react-navigation/native"; import { useCallback, useEffect, useLayoutEffect, useRef } from "react"; import { View } from "react-native"; import { hasCloudPublicConfig } from "../cloud/publicConfig"; export function SettingsAuthRouteScreen() { const navigation = useNavigation(); useLayoutEffect(() => { if (!hasCloudPublicConfig()) { navigation.dispatch(StackActions.replace("SettingsContent")); } }, [navigation]); return hasCloudPublicConfig() ? : null; } function ConfiguredSettingsAuthRouteScreen() { const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false }); const navigation = useNavigation(); const handleHostBack = useCallback( () => 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 ( {isLoaded ? ( hasBeenSignedIn.current ? ( ) : ( ) ) : null} ); }