-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrootNavigator.js
More file actions
37 lines (31 loc) · 963 Bytes
/
rootNavigator.js
File metadata and controls
37 lines (31 loc) · 963 Bytes
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
import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import Home from './Home';
import SignIn from './SignIn';
import Profile from './Profile';
import SplashScreen from './Splashscreen';
import {useAuth} from './auth';
export default function rootNavigator(props) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const {state} = useAuth();
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
if (state.isLoading) {
return <SplashScreen />;
}
return (
<>
{state.userToken ? (
<Tab.Navigator>
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="Profile" component={Profile} />
</Tab.Navigator>
) : (
<Stack.Navigator>
<Stack.Screen name="SignIn" component={SignIn} />
</Stack.Navigator>
)}
</>
);
}