Skip to content

Instantly share code, notes, and snippets.

@alexmochu
Created June 30, 2020 11:15
Show Gist options
  • Save alexmochu/e2bbc9e59355aae74a66e7162f4dc6f1 to your computer and use it in GitHub Desktop.
Save alexmochu/e2bbc9e59355aae74a66e7162f4dc6f1 to your computer and use it in GitHub Desktop.
Create Redux Store
import { applyMiddleware, createStore } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { composeWithDevTools } from 'redux-devtools-extension';
import rootReducer from './reducers';
import rootSaga from './sagas';
export default function configureStore(initialState) {
const sagaMiddleware = createSagaMiddleware();
const middlewares = [sagaMiddleware];
const middlewareEnhancer = applyMiddleware(...middlewares);
const enhancers = [middlewareEnhancer];
const composedEnhancers = composeWithDevTools(...enhancers);
const store = createStore(rootReducer, initialState, composedEnhancers);
sagaMiddleware.run(rootSaga);
return store;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment