-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
71 lines (61 loc) · 1.64 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { useCallback, useEffect, useState } from 'react';
import Entypo from '@expo/vector-icons/Entypo';
import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';
import {
useFonts,
Manrope_200ExtraLight,
Manrope_300Light,
Manrope_400Regular,
Manrope_500Medium,
Manrope_600SemiBold,
Manrope_700Bold,
Manrope_800ExtraBold,
} from '@expo-google-fonts/manrope';
import Routes from './src/routes';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { AuthProvider } from './src/contexts/AuthContext';
const queryClient = new QueryClient();
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
const [fontsLoaded] = useFonts({
Manrope_200ExtraLight,
Manrope_300Light,
Manrope_400Regular,
Manrope_500Medium,
Manrope_600SemiBold,
Manrope_700Bold,
Manrope_800ExtraBold,
});
useEffect(() => {
async function prepare() {
try {
await SplashScreen.preventAutoHideAsync();
await Font.loadAsync(Entypo.font);
if (appIsReady && fontsLoaded) {
await SplashScreen.hideAsync();
}
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, [appIsReady, fontsLoaded]);
useCallback(async () => {
if (appIsReady && fontsLoaded) {
await SplashScreen.hideAsync();
}
}, [appIsReady, fontsLoaded]);
if (!appIsReady || !fontsLoaded) {
return null;
}
return (
<QueryClientProvider client={queryClient}>
<AuthProvider>
<Routes />
</AuthProvider>
</QueryClientProvider>
);
}