-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
63 lines (54 loc) · 1.64 KB
/
Copy pathApp.js
File metadata and controls
63 lines (54 loc) · 1.64 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { NavigationContainer } from "@react-navigation/native"
import { useEffect, useState } from "react"
import { LogBox } from "react-native"
import { SafeAreaProvider } from "react-native-safe-area-context"
import { signInWithEmail } from "@api/auth"
import { getData } from "@api/storage"
import { LessonsProvider } from "@context/LessonsContext"
import { ReviewsProvider } from "@context/ReviewsContext"
import { ReferenceProvider } from "@context/ReferenceContext"
import { AppNavigator } from "@navigators/index"
LogBox.ignoreAllLogs() //Hide all warning notifications on front-end
export default function App() {
const [signedIn, setSignedIn] = useState(null)
const asyncLogin = async () => {
const storedCredentials = await getData("credentials")
try {
if (storedCredentials) {
await signInWithEmail(
storedCredentials.email,
storedCredentials.password
)
setSignedIn(true)
} else {
setSignedIn(false)
}
} catch (err) {
console.log("Invalid async storage credentials:", err)
setSignedIn(false)
}
}
useEffect(() => {
asyncLogin()
}, [])
if (signedIn === null) {
return <></>
}
return (
<SafeAreaProvider>
<NavigationContainer>
<LessonsProvider>
<ReviewsProvider>
<ReferenceProvider>
<AppNavigator
initialRouteName={
signedIn === false ? "Onboarding" : "IntoroTabs"
}
/>
</ReferenceProvider>
</ReviewsProvider>
</LessonsProvider>
</NavigationContainer>
</SafeAreaProvider>
)
}