-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
41 lines (34 loc) · 1.1 KB
/
App.js
File metadata and controls
41 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { useState, useEffect } from "react";
import { ActivityIndicator, View } from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import AppNavigator from "./navigations/AppNavigator";
import WelcomeScreen from "./screens/WelcomeScreen";
const App = () => {
const [isFirstLaunch, setIsFirstLaunch] = useState(null);
useEffect(() => {
async function checkFirstLaunch() {
try {
const hasLaunched = await AsyncStorage.getItem("hasLaunched");
if (hasLaunched === null) {
await AsyncStorage.setItem("hasLaunched", "true");
setIsFirstLaunch(true);
console.log("Check First Launch");
} else {
setIsFirstLaunch(false);
}
} catch (error) {
console.log(error);
}
}
checkFirstLaunch();
}, []);
if (isFirstLaunch === null) {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<ActivityIndicator size="large" />
</View>
);
}
return <AppNavigator isFirstLaunch={isFirstLaunch} />;
};
export default App;