Rules
no-duplicate-key
Full Name in eslint-plugin-react-x
Full Name in @eslint-react/eslint-plugin
Features
🔍
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Prevents duplicate key
on elements in the same array or a list of children
.
React uses keys to identify elements in an array. If two elements have the same key, React will not be able to distinguish them. This can lead to issues with state and rendering.
Examples
Failing
Passing
Implementation
Further Reading
See Also
no-missing-key
Prevents missingkey
on items in list rendering.no-implicit-key
Preventskey
from not being explicitly specified (e.g. spreadingkey
from objects).no-array-index-key
Warns when an arrayindex
is used as akey
prop.