-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
43 lines (38 loc) · 1.49 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
import * as React from 'react';
import MainContainer from './navigation/MainContainer';
import { NavigationContainer } from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import Login from './navigation/Login';
import { User, onAuthStateChanged } from 'firebase/auth';
import { FIREBASE_AUTH } from './firebaseConfig';
import { useState, useEffect } from 'react';
import Register from './navigation/Register';
import { LogBox } from 'react-native';
const Stack = createNativeStackNavigator();
export default function App(){
const [ user, setUser ] = useState(User | null);
LogBox.ignoreLogs(['VirtualizedLists should never be nested']);
useEffect(() => {
onAuthStateChanged(FIREBASE_AUTH, (user) => {
setUser(user);
})
}, []);
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Login">
{user ? (
<Stack.Screen name="MainContainer" options={{ headerShown: false }}>
{(props) => <MainContainer {...props} userId={user.uid} />}
</Stack.Screen>
) : (
<Stack.Screen name="Login" component={Login} options={{ headerShown: false }} />
)}
{user ? (
<Stack.Screen name="MainContainer2" component={MainContainer} options={{ headerShown: false }} />
) : (
<Stack.Screen name="Register" component={Register} options={{ headerShown: false }} />
)}
</Stack.Navigator>
</NavigationContainer>
);
}