Skip to content

no-array-index-key can be bypassed with toString #2140

@kognise

Description

@kognise

You can bypass the no-array-index-key rule with toString().

In other words, this gives an error:

foo.map((bar, index) => (
  <Element key={index} bar={bar} />
))

But this doesn't:

foo.map((bar, index) => (
  <Element key={index.toString()} bar={bar} />
))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions