-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
49 lines (42 loc) · 1.16 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
import { useEffect, useState } from 'react';
import {
Sora_400Regular,
Sora_500Medium,
Sora_600SemiBold,
Sora_700Bold,
useFonts
} from '@expo-google-fonts/sora';
import { Logs } from 'expo';
import { StatusBar } from 'expo-status-bar';
import { AsyncStorage, PersistGate, Provider } from '~/modules';
import { AppRoutes } from '~/navigation';
import { persistor, store } from '~/stores';
import { ThemeProvider } from './src/theme';
Logs.enableExpoCliLogging();
export default function App (): JSX.Element | null {
const [token, setToken] = useState<string | null>(null);
const [fontsLoaded] = useFonts({
Sora_400Regular,
Sora_500Medium,
Sora_600SemiBold,
Sora_700Bold
});
const getToken = async (): Promise<void> => {
const item = await AsyncStorage.getItem('user:token');
setToken(item);
};
useEffect(() => {
getToken();
});
if (!fontsLoaded) return null;
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ThemeProvider>
<StatusBar style="auto" />
<AppRoutes token={token} />
</ThemeProvider>
</PersistGate>
</Provider>
);
}