configureStore.js 806 Bytes
Newer Older
bert committed
1 2 3
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
bert committed
4
import promiseMiddleware from './middlewares/promiseMiddleware';
bert committed
5
import rootReducer from './reducers'
bert committed
6 7

export default function configureStore(initialState) {
bert committed
8 9 10 11 12 13 14
  const store = createStore(
    rootReducer,
    initialState,
    applyMiddleware(
      thunkMiddleware,
      createLogger(),
      promiseMiddleware({ promiseTypeSuffixes: ['PENDING', 'SUCCESS', 'ERROR'] }),
bert committed
15
    )
bert committed
16 17
    // applyMiddleware(thunkMiddleware)
  )
bert committed
18 19 20 21 22 23 24 25 26 27 28
  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {
      const nextReducer = require('../reducers').default
      store.replaceReducer(nextReducer)
    })
  }

  return store
}