-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
64 lines (55 loc) · 2.23 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
60
61
62
63
64
import React, { useState, useEffect } from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import reduxThunk from 'redux-thunk';
import { YellowBox } from 'react-native';
import { SplashScreen } from 'expo';
import * as Font from 'expo-font';
import * as firebase from 'firebase';
import { Ionicons } from '@expo/vector-icons';
import AppNavigator from './navigation/AppNavigator';
import reducers from './reducers';
import firebaseConfig from './config/firebase';
import OfflineSnackBar from './components/layout/OfflineSnackBar';
import './fix/setting-timer-bug';
firebase.initializeApp(firebaseConfig);
const store = createStore(reducers, {}, applyMiddleware(reduxThunk));
const App = ({ skipLoadingScreen }) => {
const [isLoadingComplete, setLoadingComplete] = useState(false);
// ignore yellow box warning
YellowBox.ignoreWarnings(['Warning: React']);
// Load any resources or data that we need prior to rendering the app
useEffect(() => {
async function loadResourcesAndDataAsync() {
try {
SplashScreen.preventAutoHide();
// Load fonts
await Font.loadAsync({
...Ionicons.font,
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
'montserrat-lightitalic': require('./assets/fonts/Montserrat/Montserrat-LightItalic.ttf'),
'montserrat-regular': require('./assets/fonts/Montserrat/Montserrat-Regular.ttf'),
'montserrat-semibold': require('./assets/fonts/Montserrat/Montserrat-SemiBold.ttf'),
});
} catch (e) {
// We might want to provide this error information to an error reporting service
console.warn(e);
} finally {
setLoadingComplete(true);
SplashScreen.hide();
}
}
loadResourcesAndDataAsync();
}, []);
if (!isLoadingComplete && !skipLoadingScreen) {
return null;
} else {
return (
<Provider store={store}>
<AppNavigator />
<OfflineSnackBar />
</Provider>
);
}
}
export default App;