forked from gitpoint/git-point
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.store.js
44 lines (35 loc) · 1.06 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
42
43
44
import { compose, createStore, applyMiddleware } from 'redux';
import { autoRehydrate } 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);
};
const getEnhancers = () => {
const enhancers = [];
enhancers.push(autoRehydrate());
return enhancers;
};
let store;
if (__DEV__ && process.env.TRON_ENABLED) {
store = Reactotron.createStore(
rootReducer,
compose(getMiddleware(), ...getEnhancers())
);
} else {
store = createStore(
rootReducer,
composeWithDevTools(getMiddleware(), ...getEnhancers())
);
}
export const configureStore = store;