Skip to content

Commit e37268d

Browse files
committed
fix: rename function, add verifyAppLayoutStatus
1 parent 3c63f8c commit e37268d

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

apps/native/app/index.tsx

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
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+
}

0 commit comments

Comments
 (0)