简体   繁体   English

在jsx中使用lodash forEach时出现ESlint错误

[英]ESlint error when using lodash forEach in jsx

I have a code: 我有一个代码:

  renderList = () => {
    const result = this.props.searchResult;
    const liArray = [];
    forEach({ a: 1, b: 2 }, (value, key) => {
      liArray.push(<li>hello</li>);
    });
    return (
      <ul className="text-muted m-0 p-0">{liArray}</ul>
    );
  }

The eslint is giving error : eslint给出了错误:

[eslint] Irregular whitespace not allowed. [eslint]不允许使用不规则的空格。 (no-irregular-whitespace). (无不规则的空格)。

This error is inside forEach loop. 此错误在forEach循环内。 Please help. 请帮忙。

It's likely that you have copy/pasted some invalid whitespace characters. 您可能已经复制/粘贴了一些无效的空白字符。 Just delete the whitespace and type it out by hand. 只需删除空白并手动输入即可。

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

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