-
-
Save AllGistsEqual/8522896f09e1397d19e71df07ec9269f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File: sc/screens/AppCheckScreen.tsx (partial) | |
import React, { useCallback } from 'react' | |
import { Text, View, StyleSheet } from 'react-native' | |
import { useFocusEffect } from '@react-navigation/native' | |
import { MainNavigationProp } from '../../routing/types' | |
import { MainRoutes } from '../../routing/routes' | |
import { useReduxSelector } from '../../redux' | |
import { selectLogin } from '../../redux/ducks/user' | |
type AppCheckScreenProps = { | |
navigation: MainNavigationProp<MainRoutes.AppCheck> | |
} | |
const AppCheckScreen = ({ navigation }: AppCheckScreenProps): React.ReactElement => { | |
const isLoggedIn = useReduxSelector(selectLogin) | |
const getRoute = useCallback(() => ( | |
isLoggedIn | |
? MainRoutes.AppLoading | |
: MainRoutes.SignIn | |
), [isLoggedIn]) | |
useFocusEffect( | |
useCallback(() => { | |
setTimeout(() => { | |
/* | |
* fake timer where you would instead | |
* load and check the app version | |
* and possible breaking changes before | |
* you send the user to the App Stack | |
*/ | |
navigation.navigate(getRoute()) | |
}, 1500) | |
}, [navigation, getRoute]), | |
) | |
return ( | |
<View style={styles.page}> | |
<Text>loading App Data...</Text> | |
</View> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment