我正在尝试为过滤事件添加和删除上传的 gif 图片
我哪里失败了?
@observable loading = false; //Loading variable being tracked in component
@computed get filtered() {
this.loading=true;//true
let filteredList = this.list.filter(
item => item.data.some(
obj => obj.tr_x.toLowerCase().includes(this.filterTermValue)
)
);
this.loading=false;//false
if (filteredList.length)
return filteredList;
return this.list;
}
最佳答案
什么是@computed
装饰?
它是一种缓存。如果参数没有改变,则不计算,只返回之前的计算值。
作为避免副作用的良好做法,那些 @computed
函数不能改变任何东西,只是计算幂等信息。
并且您需要查看堆栈调用以确保更改任何属性的代码未被 @computed
函数调用。
关于reactjs - 错误 : [mobx] Computed values are not allowed to cause side effects by changing observables that are already being observed. 试图修改:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58183786/
相关文章:
node.js - nodemailer 不发送邮件,给出 250 ok
google-chrome - 一些 Font Awesome 图标在 Chrome 中不显示
javascript - 使用 React Hook 应用多个 Context 的好方法
angular - 重新加载页面后保持元素位置 - 拖放 cdk Angular 7
android-studio - Android studio 在执行 lint 时找不到 kotl
python - 如何在 keras 中训练顺序模型,给出一个列表作为输出和输入?
python - 将部分训练的 scikit-learn 模型存储或检查点到磁盘