【问题标题】:Getting no-return-assign lint error for filteredArray.forEach((x) => (x.order -= 1)为 filteredArray.forEach((x) => (x.order -= 1) 获取 no-return-assign lint 错误
【发布时间】:2021-09-04 06:49:51
【问题描述】:

我使用filteredArray.forEach((x) => (x.order -= 1)); 将存储在filteredArray 中的所有元素的顺序字段减1。 现在我收到 lint 错误:Arrow function should not return assignment no-return-assign

【问题讨论】:

    标签: javascript arrays reactjs typescript-eslint


    【解决方案1】:

    您只需将() 更改为{}

    filteredArray.forEach((x) => {x.order -= 1});
    

    【讨论】:

      猜你喜欢
      • 2021-06-17
      • 1970-01-01
      • 1970-01-01
      • 2019-01-20
      • 2019-10-30
      • 1970-01-01
      • 2017-12-02
      • 1970-01-01
      • 2012-05-06
      相关资源
      最近更新 更多