javascript - How to fix eslint prefer-destructuring if we want to override defined variable?
问题描述
export const foo = (param) => {
const nextState = { fetching: false };
let value = null;
switch (param.key) {
case someCase:
value = 2;
break;
default:
value = param.value;
break;
}
nextState[param.key] = value;
return state.merge(nextState);
};
From the code above, line value = param.value
is getting eslint exception, saying prefer destructuring. I understand what destructuring is but wasnt sure how to apply in this case above because we alread have let value = null
解决方案
推荐阅读
- r - 使用霍普金斯统计评估数据集的可聚类性
- laravel - Laravel 备份命令不从控制器执行
- sql-server - SSRS - 从 SQL 格式化 datetimeoffset 值
- canvas - 如何取消显示图像 (CANVAS)
- python - 将 django models.py 拆分为文件夹内的多个文件(Django 3.0.4)
- c# - 反序列化数组中的 400 个 json 对象
- lsf - LSF 资源使用参数的困难 -
- json - 使用嵌套属性构建平面 JSON
- ruby - chromedriver 不使用 download.defaultDirectory
- docker - 如何在启用 ssh 的 docker 节点上运行 Kubernetes?