-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
54 lines (40 loc) · 1.36 KB
/
App.js
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
import "react-native-gesture-handler"
import { useState, useEffect } from "react"
import { NativeBaseProvider, StatusBar } from "native-base"
import { NavigationContainer } from "@react-navigation/native"
import { useFonts } from "expo-font"
import interFonts from "./src/assets/fonts/inter"
import josefinSansFonts from "./src/assets/fonts/josefin-sans"
import Loading from "./src/components/Loading"
import AuthRoutes from "./src/routes/auth.routes"
import AppRoutes from "./src/routes/app.routes"
import { auth } from "./src/config/firebase"
import { onAuthStateChanged } from "firebase/auth"
import theme from "./src/config/theme"
function App() {
const [user, setUser] = useState(true)
const [isLoading, setIsLoading] = useState(true)
const [fontsLoaded] = useFonts({
...interFonts,
...josefinSansFonts
})
useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, user => {
setIsLoading(false)
setUser(user)
console.log(auth.currentUser)
console.log(user)
})
return unsubscribe
}, [])
if (!fontsLoaded | isLoading) return <Loading />
return (
<NativeBaseProvider theme={theme}>
<StatusBar barStyle="dark-content" backgroundColor="white" />
<NavigationContainer>
{ user ? <AppRoutes /> : <AuthRoutes /> }
</NavigationContainer>
</NativeBaseProvider>
);
}
export default App