Commit e37268d 1 parent 3c63f8c commit e37268d Copy full SHA for e37268d
File tree 1 file changed +24
-2
lines changed
1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 1
- import OnboardingScreen from "@/screens/onboarding/Onboarding.screen" ;
2
- export default ( ) => < OnboardingScreen /> ;
1
+ import React , { useEffect , useState } from "react" ;
2
+ import { Redirect , useRouter } from "expo-router" ;
3
+ import AsyncStorage from "@react-native-async-storage/async-storage" ;
4
+
5
+ export default function InitialRoute ( ) {
6
+ const [ shouldShowOnboarding , setShouldShowOnboarding ] = useState ( false ) ;
7
+ const router = useRouter ( ) ;
8
+
9
+ useEffect ( ( ) => {
10
+ const verifyAppLaunchStatus = async ( ) => {
11
+ const hasCompletedOnboarding = await AsyncStorage . getItem ( "hasLaunched" ) ;
12
+
13
+ if ( hasCompletedOnboarding === null ) {
14
+ setShouldShowOnboarding ( true ) ;
15
+ } else {
16
+ router . replace ( "/(auth)/login" ) ;
17
+ }
18
+ } ;
19
+
20
+ verifyAppLaunchStatus ( ) ;
21
+ } , [ router ] ) ;
22
+
23
+ return shouldShowOnboarding ? < Redirect href = "/onboarding" /> : null ;
24
+ }
You can’t perform that action at this time.
0 commit comments