Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript hanlde使用saga和axios上传进度_Javascript_Reactjs_React Redux_Redux Saga_Saga - Fatal编程技术网

Javascript hanlde使用saga和axios上传进度

Javascript hanlde使用saga和axios上传进度,javascript,reactjs,react-redux,redux-saga,saga,Javascript,Reactjs,React Redux,Redux Saga,Saga,我试图在react中创建进度条。上传文件后,出现以下错误: 错误:调用:{context,fn}类型的参数未定义或为nullfn saga.js: const identity = a => a; const createAsync = file => { let emit; const chan = eventChannel(emitter => { emit = emitter; return () => {}; }); const

我试图在react中创建进度条。上传文件后,出现以下错误: 错误:调用:{context,fn}类型的参数未定义或为null
fn

saga.js:

const identity = a => a;

const createAsync = file => {
  let emit;
  const chan = eventChannel(emitter => {
    emit = emitter;
    return () => {};
  });
  const promise = uploadVideoApi(file, function(e) {
    emit((e.loaded * 100) / e.total);
  });

  return [promise, chan];
};

function* watchOnProgress(chan) {
  while (true) {
    const data = yield take(chan);
    yield put(uploadFileProgress(data));
  }
}

function* uploadVideo({ file }) {
  const [promise, chan] = createAsync(file);
  yield fork(watchOnProgress, chan);
  const result = yield call(identity(promise));
}
actions.js:

export function uploadFileProgress(percent) {
  return {
    type: UPLOAD_VIDEO_PROGRESS,
    percent,
  };
}


call
来自哪里?如果您打算使用
Function.prototype.call()
,那么您需要知道这是一种只能在函数实例上运行的方法,在这种情况下,
identity.call(promise)
?调用文档:@DoriAviram它来自redux saga effects。来源:你不能在承诺中使用
call
。如果您想等待承诺,只需执行
屈服承诺
参考此处:可能是重复问题