Skip to content

Instantly share code, notes, and snippets.

@LukeSmetham
Created September 20, 2019 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LukeSmetham/03e057f41f710316874cdfe950d51f42 to your computer and use it in GitHub Desktop.
Save LukeSmetham/03e057f41f710316874cdfe950d51f42 to your computer and use it in GitHub Desktop.
import { compose, createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import thunkMiddleware from 'redux-thunk';
import createReducer from './createReducer';
import sagas from './rootSaga';
let store;
export default () => {
const reducer = createReducer();
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const middleware = [];
const sagaMiddleware = createSagaMiddleware();
middleware.push(sagaMiddleware);
middleware.push(thunkMiddleware);
store = createStore(reducer, composeEnhancers(applyMiddleware(...middleware)));
sagaMiddleware.run(sagas);
return store;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment