import { createStore , applyMiddleware , Store } from 'redux' ; import logger from 'redux-logger' ; import createSagaMiddleware , { Task } from 'redux-saga' ; import { Context , createWrapper } from 'next-redux-wrapper' ; import reducer , { State } from './reducer' ; import rootSaga from './saga' ; export interface SagaStore extends Store < State > { sagaTask : Task ; } const makeStore = ( context ) => { const sagaMiddleware = createSagaMiddleware ( ) ; const store = createStore ( reducer , applyMiddleware ( sagaMiddleware , logger ) ) ; ( store as SagaStore ) . sagaTask = sagaMiddleware . run ( rootSaga ) ; return store ; } ; export const wrapper = createWrapper < SagaStore > ( makeStore as any ) ;