Skip to content

Commit 4ef2810

Browse files
committed
Add more explicit reasoning to no-array-index-key docs
This makes the intention of this rule clearer.
1 parent c00c684 commit 4ef2810

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/rules/no-array-index-key.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Warn if an element uses an Array index in its `key`.
44

55
The `key` is used by React to [identify which items have changed, are added, or are removed and should be stable](https://facebook.github.io/react/docs/lists-and-keys.html#keys).
66

7+
It's a bad idea to use the array index since it doesn't uniquely identify your elements. In cases where the array is sorted or an element is added to the beginning of the array, the index will be changed even though the element representing that index may be the same. This results in in unnecessary renders.
8+
79
## Rule Details
810

911
The following patterns are considered warnings:

0 commit comments

Comments
 (0)