【发布时间】:2019-10-31 21:41:07
【问题描述】:
为什么我不能以这种方式返回新状态(重置操作)?
export interface TodosModel {
items: string[];
reset: Action<TodosModel>;
}
const todos: TodosModel = {
items: [],
// This action does not update the state
reset: action(() => {
return {
items: []
};
})
};
我正在努力实现这里描述的内容:https://github.com/ctrlplusb/easy-peasy/issues/146
工作示例:https://codesandbox.io/s/easy-peasy-typescript-v3-vzc11
【问题讨论】:
-
你能不能减少例子,至少把重要的部分贴在这里。您在这个问题中的 sn-p 看起来像一个动作生成器,而不是状态。
-
我已经更新了问题描述
-
你好。请更新到允许您在操作中返回新状态的最新版本。 ??????
标签: reactjs typescript redux easy-peasy