-
Notifications
You must be signed in to change notification settings - Fork 789
/
root.store.js
41 lines (35 loc) · 1.05 KB
/
root.store.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
import { compose, createStore, applyMiddleware } from 'redux';
import { persistStore } from 'redux-persist';
import Reactotron from 'reactotron-react-native'; // eslint-disable-line import/no-extraneous-dependencies
import createLogger from 'redux-logger';
import reduxThunk from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension';
import 'config/reactotron';
import rootReducer from './root.reducer';
const getMiddleware = () => {
const middlewares = [reduxThunk];
if (__DEV__) {
if (process.env.LOGGER_ENABLED) {
middlewares.push(createLogger());
}
}
return applyMiddleware(...middlewares);
};
let store;
if (__DEV__) {
if (process.env.TRON_ENABLED) {
store = Reactotron.createStore(
rootReducer,
compose(getMiddleware())
);
} else {
store = createStore(
rootReducer,
composeWithDevTools(getMiddleware())
);
}
} else {
store = createStore(rootReducer, compose(getMiddleware()));
}
export const configureStore = store;
export const persistor = persistStore(configureStore);