-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
66 lines (53 loc) · 1.56 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
65
66
// @flow
// react
import React from 'react'
import { Font } from 'expo'
// redux
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import { createLogger } from 'redux-logger'
import reduxThunk from 'redux-thunk'
import reduxPromise from 'redux-promise'
import { persistStore, persistReducer } from 'redux-persist'
import { PersistGate } from 'redux-persist/integration/react'
import storage from 'redux-persist/lib/storage'
import rootReducer from './src/state/reducers'
// components
import Navigator from './src/containers/navigators/Navigator'
const persistConfig = {
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
const logger = createLogger({ collapsed: true })
const store = createStore(
persistedReducer,
applyMiddleware(reduxThunk, reduxPromise, logger),
)
const persistor = persistStore(store)
type State = {
fontLoaded: boolean,
}
type Props = {}
export default class App extends React.PureComponent<Props, State> {
state = { fontLoaded: false }
async componentDidMount() {
await Font.loadAsync({
'Gotham-Medium': require('./assets/fonts/gotham-medium.ttf'),
})
await Font.loadAsync({
'Gotham-Book': require('./assets/fonts/gotham-book.ttf'),
})
this.setState({ fontLoaded: true })
}
render() {
const { fontLoaded } = this.state
return fontLoaded ? (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Navigator />
</PersistGate>
</Provider>
) : null
}
}