Skip to content

Instantly share code, notes, and snippets.

@hroland
Created August 10, 2019 13:29
Show Gist options
  • Save hroland/8fe9bafd84b01796f9d8cb27057cc4f6 to your computer and use it in GitHub Desktop.
Save hroland/8fe9bafd84b01796f9d8cb27057cc4f6 to your computer and use it in GitHub Desktop.
import { AppLoading } from 'expo';
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import React, { useState } from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { Ionicons, Feather, MaterialCommunityIcons } from '@expo/vector-icons';
import AppNavigator from './navigation/AppNavigator';
export default function App(props) {
const [isLoadingComplete, setLoadingComplete] = useState(false);
if (!isLoadingComplete && !props.skipLoadingScreen) {
return (
<AppLoading
startAsync={loadResourcesAsync}
onError={handleLoadingError}
onFinish={() => handleFinishLoading(setLoadingComplete)}
/>
);
} else {
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
</View>
);
}
}
async function loadResourcesAsync() {
await Promise.all([
Asset.loadAsync([
]),
Font.loadAsync({
...Ionicons.font,
...Feather.font,
...MaterialCommunityIcons.font,
}),
]);
}
function handleLoadingError(error) {
// In this case, you might want to report the error to your error reporting
// service, for example Sentry
console.warn(error);
}
function handleFinishLoading(setLoadingComplete) {
setLoadingComplete(true);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment