[英]How to solve this Reactjs Eslint warning about 'index' is defined but never used
You're not using the index returned from the map function.您没有使用从 map 函数返回的索引。 You're declaring 'id' inside of it and assigning a value returned from "uniqueId" somewhere else in your code.
您在其中声明了 'id' 并在代码中的其他地方分配了从“uniqueId”返回的值。
This is not a bug.这不是一个错误。
If you don't want to see the warning, you could:如果您不想看到警告,您可以:
_
, that way eslint will understand that you're discarding that parameter_
替换它,这样 eslint 就会明白你正在丢弃那个参数Edit: As pointed by Brian Thompson, you probably want to use the index anyway, to get a unique id without having to create one by yourself:编辑:正如 Brian Thompson 所指出的,您可能无论如何都想使用索引来获得唯一的 id,而不必自己创建一个:
Resume.article.map((element, idx) => {
articles.push(
<div className="column" key={idx}>
...
</div>
)
}
You're not using/referencing index
anywhere, so just remove it from the parameters.您没有在任何地方使用/引用
index
,因此只需将其从参数中删除即可。 You don't need it.你不需要它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.