-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
48 lines (41 loc) · 1.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
import React from 'react'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware, combineReducers } from 'redux'
import { RootNavigation } from './src/navigator/AppNavigator'
import { persistStore, persistReducer } from 'redux-persist'
import thunk from 'redux-thunk'
import logger from 'redux-logger'
import { PersistGate } from 'redux-persist/integration/react'
import FSStorage from 'redux-persist-fs-storage'
import authors from './src/reducers/authors'
import posts from './src/reducers/posts'
import common from './src/reducers/common'
const persistConfig = {
key: 'root',
storage: FSStorage(),
keyPrefix: '',
blacklist: ['common'],
}
const AppReducer = combineReducers({
authors,
feed: posts,
common,
})
const middlewares = [thunk]
if (__DEV__) {
middlewares.push(logger)
}
const persistedReducer = persistReducer(persistConfig, AppReducer)
const store = createStore(persistedReducer, applyMiddleware(...middlewares))
export const persistor = persistStore(store)
export default class App extends React.Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<RootNavigation />
</PersistGate>
</Provider>
)
}
}