Initial commit
Generated by create-expo-app 3.3.0.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { Stack, useRouter } from "expo-router";
|
||||
import "@/global.css";
|
||||
import { Platform } from "react-native";
|
||||
import { AuthProvider, useAuth } from "@/utils/AuthProvider";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
const InitialLayout = () => {
|
||||
const isWeb = Platform.OS === "web";
|
||||
|
||||
const router = useRouter();
|
||||
const { isAuthenticated, isLoaded } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoaded && isAuthenticated) {
|
||||
router.replace("/(app)/(authenticated)/home");
|
||||
}
|
||||
}, [isLoaded, isAuthenticated]);
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<Stack.Screen name="(app)" options={{ headerShown: false }} />
|
||||
|
||||
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||
|
||||
<Stack.Screen
|
||||
name="register"
|
||||
options={{ headerShown: isWeb ? false : true, title: "Register" }}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default function RootLayout() {
|
||||
return (
|
||||
<AuthProvider>
|
||||
<InitialLayout />
|
||||
</AuthProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user