This repository was archived by the owner on Aug 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
43 lines (37 loc) · 1.31 KB
/
App.js
File metadata and controls
43 lines (37 loc) · 1.31 KB
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
import React, { useState, useEffect } from "react";
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/lib/integration/react";
import { persistor, store } from "./src/helpers";
import { AppNavigator, LoadingScreen } from "./src/components/common";
import { Asset } from "expo-asset";
import * as Font from "expo-font";
export default function() {
const [isReady, setIsReady] = useState(false);
useEffect(() => {
_loadResourcesAsync()
.then(_handleFinishLoading)
.catch(_handleLoadingError);
}, []);
const _loadResourcesAsync = async () => {
// const cacheAssets = Asset.loadAsync();
const cacheFonts = Font.loadAsync({
normalFont: require("./assets/fonts/Poppins-Regular.otf"),
boldFont: require("./assets/fonts/Poppins-Bold.otf"),
lightFont: require("./assets/fonts/Poppins-Light.otf"),
italicFont: require("./assets/fonts/Poppins-Italic.otf")
});
return Promise.all([cacheFonts]);
};
const _handleLoadingError = error => console.warn(error);
const _handleFinishLoading = () => {
setIsReady(true);
};
if (!isReady) return <LoadingScreen />;
return (
<Provider store={store}>
<PersistGate loading={<LoadingScreen />} persistor={persistor}>
<AppNavigator />
</PersistGate>
</Provider>
);
}