Skip to content

Instantly share code, notes, and snippets.

@malihassan20
Created January 17, 2018 21:13
Show Gist options
  • Save malihassan20/14b73b1a696abc984ff57aafa74713bb to your computer and use it in GitHub Desktop.
Save malihassan20/14b73b1a696abc984ff57aafa74713bb to your computer and use it in GitHub Desktop.
nextJs-tour-diary-app\store\store.js
import { createStore, applyMiddleware } from 'redux';
import withRedux from 'next-redux-wrapper';
import nextReduxSaga from 'next-redux-saga';
import createSagaMiddleware from 'redux-saga';
import rootReducer, { initialState } from './reducer';
import rootSagas from './saga';
const sagaMiddleware = createSagaMiddleware();
export function configureStore(state = initialState) {
const store = createStore(rootReducer, state, applyMiddleware(sagaMiddleware));
store.sagaTask = sagaMiddleware.run(rootSagas);
return store;
}
export function withReduxSaga(BaseComponent) {
return withRedux(configureStore)(nextReduxSaga(BaseComponent));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment