-
Notifications
You must be signed in to change notification settings - Fork 1
/
store.js
executable file
·38 lines (31 loc) · 1.14 KB
/
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
import { createStore, applyMiddleware, combineReducers } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension'
import { todosReducer } from './reducers/todosReducer'
import { authReducer } from './reducers/authReducer'
import { jokesReducer } from './reducers/jokesReducer'
import { reducer as formReducer } from 'redux-form';
export const initStore = (initialState = {}) => {
// mirror of state from original app
const reducers = combineReducers({
todos: todosReducer,
user: authReducer,
jokes: jokesReducer,
form: formReducer
})
let env = process.env.NODE_ENV || 'development'
if (typeof window !== 'undefined' && env === 'development' ) {
// const composeEnhancers = composeWithDevTools({
// // Specify here name, actionsBlacklist, actionsCreators and other options if needed
// actionsBlacklist: ['TICK']
// });
return createStore(
reducers,
initialState,
composeWithDevTools(
applyMiddleware(thunkMiddleware)
)
)
}
return createStore(reducers, initialState, applyMiddleware(thunkMiddleware))
}