简体   繁体   English

关于解构的警告

[英]Eslint warning about deconstruction

How would I use array destructuring on this. 我将如何在此上使用数组解构。 I'm getting a linter waring. 我收到了一个警告。

Use array destructuring. [prefer-destructuring]

const block = Object.entries(products).reduce((acc, item) => {
      acc[item[0]] = item[1];
      return acc;
    }, {}

); );

Destructure item in the parameter list into [key, val] : 解构item参数列表进入[key, val]

const block = Object.entries(products).reduce((acc, [key, val]) => {
  acc[key] = val;
  return acc;
}, {});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM