-
-
Save malihassan20/14b73b1a696abc984ff57aafa74713bb to your computer and use it in GitHub Desktop.
nextJs-tour-diary-app\store\store.js
This file contains 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 { 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