Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Created September 15, 2020 10:33
Show Gist options
  • Save indreklasn/63df76923d3eeb2aee8b358592f46f91 to your computer and use it in GitHub Desktop.
Save indreklasn/63df76923d3eeb2aee8b358592f46f91 to your computer and use it in GitHub Desktop.
import { applyMiddleware, createStore } from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunkMiddleware from 'redux-thunk'
import monitorReducersEnhancer from './enhancers/monitorReducers'
import loggerMiddleware from './middleware/logger'
import rootReducer from './reducers'
export default function configureStore(preloadedState) {
const middlewares = [loggerMiddleware, thunkMiddleware]
const middlewareEnhancer = applyMiddleware(...middlewares)
const enhancers = [middlewareEnhancer, monitorReducersEnhancer]
const composedEnhancers = composeWithDevTools(...enhancers)
const store = createStore(rootReducer, preloadedState, composedEnhancers)
if (process.env.NODE_ENV !== 'production' && module.hot) {
module.hot.accept('./reducers', () => store.replaceReducer(rootReducer))
}
return store
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment