【发布时间】:2020-02-14 15:29:09
【问题描述】:
我们的一位开发人员建议最好不要使用类来构建 redux 存储,但没有给出具体原因,主要是说“它不是惯用的,并且类在 ES6 中没有很好的实现;最好避免在 React 中使用类”。
以这种方式构建 redux 存储是否存在任何问题(即使它实际上不是行业标准?)?
class Item {
public name: string;
}
class ItemState {
public items: Item[];
public currentItem: Item;
}
// redux store
class AppState {
public Items = new ItemState();
}
// then createStore(/*reducer*/, new AppState())
【问题讨论】:
标签: typescript ecmascript-6 react-redux