gpt4 book ai didi

javascript - 将 Reflux Stores 迁移到 ES6 语法

转载 作者:行者123 更新时间:2023-11-30 16:21:58 25 4
gpt4 key购买 nike

我一直在尝试将一些现有的 React-Reflux 代码重构为 ES-6 语法,

我有 3 个商店,分别针对人员、项目和事件。它们基本上做同样的事情,但调用不同的 API 来获取结果。

所以我尝试执行以下操作:

class ResultStore extends Reflux.Store {
constructor(resultsAPI){
super();
//initializations
}
}
class PeopleResultStore extends ResultStore {
constructor(){
super('peopleBySkill');
}
}

但这开始在代码库中的随机位置(主要是在完全不相关的商店的导出语句中)抛出错误“ super 表达式必须为空或函数,而不是未定义的”。我使用的是 React 的 0.14.3 版和 Reflux 的 0.3.0 版

最佳答案

Reflux.StoreReflux.Component for ES6 usage 是刚刚实现的新功能,可以在 Reflux 中使用。您之前提到的页面只是有人提到他们想要这样的功能。当时尚未实现,该页面上讨论的内容不一定准确反射(reflect)其实现方式。

有关它们当前如何实现的文档在此处:https://github.com/reflux/refluxjs#react-es6-usage

关于javascript - 将 Reflux Stores 迁移到 ES6 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34611030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com