-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
53 lines (46 loc) · 1.3 KB
/
App.js
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
import { Provider } from "react-redux";
import { store, persistor } from "./src/redux/store";
import Main from "./src/Main";
import { useCallback, useEffect, useState } from "react";
// import AppLoading from "expo-app-loading";
import * as SplashScreen from "expo-splash-screen";
import * as Font from "expo-font";
import { View, Text } from "react-native";
import { PersistGate } from "redux-persist/integration/react";
SplashScreen.preventAutoHideAsync();
const fetchFonts = async () =>
await Font.loadAsync({
"readex-pro": require("./assets/ReadexPro.ttf"),
});
export default function App() {
const [initialized, setInitialized] = useState(false);
useEffect(() => {
fetchFonts()
.then(() => {
setInitialized(true);
})
.catch((e) => {
setInitialized(true);
});
}, []);
const onLayoutRootView = useCallback(async () => {
if (initialized) {
await SplashScreen.hideAsync();
}
}, [initialized]);
if (!initialized) {
return null;
}
return (
<Provider store={store}>
<PersistGate loading={<Text>Loading...</Text>} persistor={persistor}>
<View
style={{ width: "100%", height: "100%" }}
onLayout={onLayoutRootView}
>
<Main />
</View>
</PersistGate>
</Provider>
);
}