1import * as SplashScreen from 'expo-splash-screen'; 2import * as React from 'react'; 3import { Platform, StatusBar } from 'react-native'; 4import { AppearanceProvider } from 'react-native-appearance'; 5 6import RootNavigation from './src/navigation/RootNavigation'; 7import loadAssetsAsync from './src/utilities/loadAssetsAsync'; 8 9function useSplashScreen(loadingFunction: () => void | Promise<void>) { 10 const [isLoadingCompleted, setLoadingComplete] = React.useState(false); 11 12 // Load any resources or data that we need prior to rendering the app 13 React.useEffect(() => { 14 async function loadAsync() { 15 try { 16 await SplashScreen.preventAutoHideAsync(); 17 await loadingFunction(); 18 } catch (e) { 19 // We might want to provide this error information to an error reporting service 20 console.warn(e); 21 } finally { 22 setLoadingComplete(true); 23 SplashScreen.hideAsync(); 24 } 25 } 26 27 loadAsync(); 28 }, []); 29 30 return isLoadingCompleted; 31} 32 33export default function App(props: any) { 34 const isLoadingCompleted = useSplashScreen(async () => { 35 if (Platform.OS === 'ios') { 36 StatusBar.setBarStyle('dark-content', false); 37 } 38 await loadAssetsAsync(); 39 }); 40 41 if (!isLoadingCompleted) { 42 return null; 43 } 44 45 return ( 46 <AppearanceProvider> 47 <RootNavigation {...props} /> 48 </AppearanceProvider> 49 ); 50} 51