Skip to content

Commit 53e0722

Browse files
chnakamuraljharb
authored andcommitted
[Docs] jsx-key: improve example
Using an index for a key is a violation of the [no-array-index-key](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md) lint rule
1 parent 7dfcbfb commit 53e0722

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
3232
* [Docs] [`forbid-foreign-prop-types`]: document `allowInPropTypes` option ([#1815][] @ljharb)
3333
* [Refactor] [`jsx-sort-default-props`]: remove unnecessary code ([#1817][] @ljharb)
3434
* [Docs] [`jsx-no-target-blank`]: fix syntax highlighting ([#3199][] @shamrin)
35+
* [Docs] [`jsx-key`]: improve example ([#3202][] @chnakamura)
3536

37+
[#3202]: https://github.com/yannickcr/eslint-plugin-react/pull/3202
3638
[#3199]: https://github.com/yannickcr/eslint-plugin-react/pull/3199
3739
[#3198]: https://github.com/yannickcr/eslint-plugin-react/pull/3198
3840
[#3195]: https://github.com/yannickcr/eslint-plugin-react/pull/3195

docs/rules/jsx-key.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Examples of **correct** code for this rule:
2222
```jsx
2323
[<Hello key="first" />, <Hello key="second" />, <Hello key="third" />];
2424

25-
data.map((x, i) => <Hello key={i}>{x}</Hello>);
25+
data.map((x) => <Hello key={x.id}>{x}</Hello>);
2626

2727
<Hello key={id} {...{ id, caption }} />
2828
```

0 commit comments

Comments
 (0)