我尝试使用redux-saga-watch-actions
库,但是现在我在整个Internet上遇到了一些无法解决的错误。我之所以无法想象,是因为我按照这个有用软件包的原始手册中所述进行了所有操作。
我的sagaHelper文件
import createSagaMiddleware from 'redux-saga'
import createSagaMiddlewareHelpers from 'redux-saga-watch-actions/lib/middleware'
import watchSearch from '../routes/watchSearch/modules/saga'
import watchHub from '../modules/saga'
const sagaMiddleware = createSagaMiddleware()
const runSaga = saga => sagaMiddleware.run(saga)
const { injectSaga, cancelTask } = createSagaMiddlewareHelpers(runSaga) // that is where I got an error
export const rootSaga = function * () {
yield all([
watchHub(),
watchSearch()
])
}
export { cancelTask, injectSaga, runSaga }
export default sagaMiddleware
我的createStore文件:
import saga, { rootSaga, runSaga } from '../saga/sagaHelper'
export default (initialState = {}) => {
const store = createStore(
makeRootReducer(),
initialState,
compose(responsiveStoreEnhancer, applyMiddleware(saga))
)
store.runSaga = runSaga
runSaga(rootSaga)
return store
}
使用过的Webpack 3.8.1,React 16. Redux-最新