Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created April 18, 2021 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllGistsEqual/cf129ca33c522cd8304b0a2f9c48fafa to your computer and use it in GitHub Desktop.
Save AllGistsEqual/cf129ca33c522cd8304b0a2f9c48fafa to your computer and use it in GitHub Desktop.
// File: src/routing/MainNavigation.tsx
import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { MainStack, MainRoutes } from './routes'
/* new */ import { useReduxSelector } from '../redux'
/* new */ import { selectLogin } from '../redux/ducks/user'
import SplashScreen from '../screens/SplashScreen'
import AppLoadingScreen from '../screens/AppLoadingScreen'
import HomeScreen from '../screens/HomeScreen'
import SettingsScreen from '../screens/SettingsScreen'
const MainNavigation = (): React.ReactElement => {
const isLoggedIn = useReduxSelector(selectLogin)
return (
<NavigationContainer>
<MainStack.Navigator headerMode="none">
{isLoggedIn ? (
<>
<MainStack.Screen name={MainRoutes.Loading} component={AppLoadingScreen} />
<MainStack.Screen name={MainRoutes.Home} component={HomeScreen} />
<MainStack.Screen name={MainRoutes.Settings} component={SettingsScreen} />
</>
) : (
<MainStack.Screen name={MainRoutes.Splash} component={SplashScreen} />
)}
</MainStack.Navigator>
</NavigationContainer>
)
}
export default MainNavigation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment