我的史诗有问题,请帮我找出哪里出错了。谢谢!
以下代码导致我出现错误:
const loginEpic = (action$) =>
action$
.ofType('LOGIN')
.switchMap(() => {
return Observable.fromPromise(loginService())
.map((result) => {
return Observable.of({
payload: result,
type: types.loginCompleted,
});
})
.catch((error) => {
return Observable.of({
payload: error,
type: types.loginFailed,
});
});
});
这是我的 configureStore 文件:
const epicMiddleware = createEpicMiddleware(rootEpic);
// Ref: https://redux-observable.js.org/docs/recipes/HotModuleReplacement.html
if (module.hot) {
module.hot.accept('./epic', () => {
const nextEpic = require('./epic');
epicMiddleware.replaceEpic(nextEpic);
});
}
const configureStore = (): Store<any> => {
const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(epicMiddleware)));
if (module.hot) {
module.hot.accept('./reducer', () => {
const nextReducer = require('./reducer').default;
store.replaceReducer(nextReducer);
});
return store;
}
};