reactjs - Redux-saga 没有在我的 reactJS 应用程序中运行
问题描述
我有我非常简单的测试传奇:
export function* helloSaga() {
console.log('Hello Sagas!')
}
我是这样称呼它的:
import reducer from "./Redux/rootReducer";
import {helloSaga} from "./Redux/Sagas/saga";
const sagaMiddleware = createSagaMiddleware();
export const store = createStore(
reducer,
applyMiddleware(sagaMiddleware),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() // chrome devtools thing
);
sagaMiddleware.run(helloSaga())
但我得到了错误× Error: runSaga(options, saga, ...args): saga argument must be a Generator function!
。请问有什么建议吗?
解决方案
看起来您传递了生成器函数的结果而不是函数本身,如下所示:
sagaMiddleware.run(helloSaga)
推荐阅读
- python - 如何让 Flask_restplus 使用来自 app_errorhandler 的错误处理程序?
- ms-access - 错误:“操作必须使用可更新的查询” - MS Access
- clojure - 无法从 Eclipse 运行 clara rules clojure 程序
- sql - 从 CSV 导入事务:错误:平面文件源 1 未通过预执行阶段并返回错误代码 0xC020200E
- composite-primary-key - 如何在 clickhouse 中为数据库设置复合主键?
- java - Magnolia 6.0 Tomcat 9 禁止访问 /.resources*
- python - 在 conda/MacOS 上使用 pip 安装 mmh3 包
- javascript - 如何删除子数组中的重复项?
- reactjs - React Native 遍历数组对象并计算总和值
- vue.js - 如何在 webpack 中正确注入 app 元素?- 接收 [Vue 警告]:找不到元素:#app