Created
March 5, 2020 17:48
-
-
Save bogoslavskiy/3ea6bb069178d9fd31eaf0e2e2ea24ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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