TypeError: You provided an invalid object where a stream was expected. Redux-observal Problem

TypeError: You provided an invalid object where a stream was expected. Redux-observal Problem

伙计们。 我在 redux-observable 中遇到问题。预先感谢您的回答。 enter image description here

//action.js

import { map,mergeMap } from 'rxjs/operators';
import {ofType } from 'redux-observable'
import { ajax } from 'rxjs/ajax';



const fetchUser = username => ({ type: 'FETCH_USER', payload: username });
export const fetchUserFulfilled = payload => ({ type: 'FETCH_USER_FULFILLED', payload });

export const fetchUserEpic = action$ => action$.pipe(
  ofType('FETCH_USER'),
  mergeMap(action =>
    ajax.getJSON(`https://api.github.com/users/${action.payload}`).pipe(
      map(response => fetchUserFulfilled(response))
    )
  )
);

export default fetchUser

商店

const epicMiddleware = createEpicMiddleware();
const store = createStore(rootReducer,applyMiddleware(epicMiddleware))

epicMiddleware.run(rootEpic);

我找到了答案。不是redux-observable的问题。

我导入了 epic 而不是 action creators 并在 React 组件中使用它。

谢谢。