-
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.37 KB
/
App.js
File metadata and controls
41 lines (34 loc) · 1.37 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 { useEffect, useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { GoogleSignin } from '@react-native-google-signin/google-signin';
import auth from '@react-native-firebase/auth';
import Welcome from './screens/Welcome';
import Home from './screens/Home';
import { UserProvider } from './components/UserContext';
const Stack = createNativeStackNavigator();
GoogleSignin.configure({
webClientId: '141106545956-8ob7cgjtr032bqn8nsta9qh7ifi1pe0n.apps.googleusercontent.com',
});
export default function App() {
const [initializing, setInitializing] = useState(true);
const [user, setUser] = useState();
const onAuthStateChanged = (user) => {
setUser(user);
if (initializing) setInitializing(false);
}
useEffect(() => {
return auth().onAuthStateChanged(onAuthStateChanged);
}, []);
if (initializing) return null;
return (
<UserProvider user={user} setUser={setUser} >
<NavigationContainer>
<Stack.Navigator initialRouteName={!user ? "welcome" : "home"}>
<Stack.Screen name='welcome' component={Welcome} options={{ headerShown: false }} />
<Stack.Screen name='home' component={Home} options={{ headerShown: false }} />
</Stack.Navigator>
</NavigationContainer>
</UserProvider>
)
}