Created
September 15, 2020 10:33
-
-
Save indreklasn/63df76923d3eeb2aee8b358592f46f91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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