Skip to content

Instantly share code, notes, and snippets.

@bogoslavskiy
Created March 5, 2020 17:48
Show Gist options
  • Save bogoslavskiy/3ea6bb069178d9fd31eaf0e2e2ea24ce to your computer and use it in GitHub Desktop.
Save bogoslavskiy/3ea6bb069178d9fd31eaf0e2e2ea24ce to your computer and use it in GitHub Desktop.
import * as React from 'react';
import { AppLoading } from 'expo';
import { ApolloProvider } from '@apollo/client';
import { client } from './graphql/client';
import { Routes } from './navigation/Routes';
import { AuthProvider, getUserFromStorage } from './contexts/AuthContext';
const App = ({ skipLoadingScreen }: { skipLoadingScreen: boolean }) => {
const [isLoadingComplete, setLoadingComplete] = React.useState(false);
if (!isLoadingComplete && !skipLoadingScreen) {
return (
<AppLoading
startAsync={loadResourcesAsync}
onError={(error: any) => {
console.warn(error);
}}
onFinish={() => setLoadingComplete(true)}
/>
);
}
return (
<ApolloProvider client={client}>
<AuthProvider>
<Routes />
</AuthProvider>
</ApolloProvider>
);
};
const loadResourcesAsync = async () => {
await Promise.all([
getUserFromStorage(),
]);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment