当我运行我的传奇时,我有这个错误“错误:调用:参数 [对象对象] 不是函数”

Mic*_*hem 2 react-native redux redux-saga

当我的动作创建者触发 mi saga 时,我有错误

"Error: call: argument [object Object] is not a function
    at check (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:126468:13)
    at getFnCallDesc (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127645:22)
    at call (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127658:25)
    at loginRequestSaga$ (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:128869:38)
    at tryCatch (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:21519:19)
    at Generator.invoke [as _invoke] (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:21694:24)
    at Generator.prototype.(anonymous function) [as next] (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:21562:23)
    at next (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127025:29)
    at proc (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127000:5)
    at runForkEffect (blob:file:///95bb5b45-c4c5-44db-9d56-d4dcee551ace:127241:21)"
Run Code Online (Sandbox Code Playgroud)

我正在运行 react native 0.57 和最新版本的 redux saga

这是我的传奇

import { put, call, select } from 'redux-saga/effects';
import { userServices } from '../../services';
import { userActions } from '../actions';
import { userConstants } from '../../constants/user.constants';

function* loginRequestSaga(action) {
  try {
    const data = yield call(userServices.fetchUser(action.credentials));
    yield put(userActions.loginSucess(data));
  } catch (e) {
    console.log(e);
  }
}

export const userSaga = {
  loginRequestSaga,
};
Run Code Online (Sandbox Code Playgroud)

预先感谢您的帮助

Abu*_*fia 5

我试图回答您的确切问题,但如果不查看您的其余代码就很难知道,所以请原谅猜测。

call(fn, args) 需要一个函数,然后是一些 args,所以你可能想要:

function* loginRequestSaga(action) {
  try {
    //next line has changed
    const data = yield call(userServices.fetchUser, action.credentials); 
    yield put(userActions.loginSucess(data));
  } catch (e) {
    console.log(e);
  }
}
Run Code Online (Sandbox Code Playgroud)