-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
59 lines (46 loc) · 1.43 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
54
55
56
57
58
59
import React, {useState} from 'react';
import {applyMiddleware, createStore} from 'redux';
import {Provider} from 'react-redux';
import ReduxThunk from 'redux-thunk';
import * as Font from 'expo-font';
import AppLoading from 'expo-app-loading';
import {LogBox} from 'react-native';
import {Asset} from 'expo-asset';
import images from './assets/images.js'
import reducer from './redux/reducer';
import MainNavigator from './Components/Navigator.js';
LogBox.ignoreLogs(['Setting a timer'])
const store = createStore(reducer, applyMiddleware(ReduxThunk));
const fetchFonts = () => {
return Font.loadAsync({
'roboto': require('./assets/Roboto-Regular.ttf'),
})
}
const fetchImages = async () => {
const cacheImages = images.map(image => {
return Asset.fromModule(image).downloadAsync()
})
return Promise.all(cacheImages)
}
async function loadResourcesAsync() {
const fontAssets = fetchFonts()
const imageAssets = fetchImages()
await Promise.all([fontAssets, imageAssets])
}
export default function App() {
const [assetsLoaded, setAssetsLoaded] = useState(false);
if (!assetsLoaded) {
return (
<AppLoading
startAsync={loadResourcesAsync}
onFinish={()=>setAssetsLoaded(true)}
onError={console.warn}
/>
);
}
return (
<Provider store={store}>
<MainNavigator/>
</Provider>
);
}