Skip to content

Commit f128396

Browse files
authored
Added key object spread example
Spreaded key is discouraged and currently triggering the rule. Added some clarification to the doc. Resolves #1753.
1 parent 9346eb8 commit f128396

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/rules/jsx-key.md

+6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@ The following patterns are considered warnings:
1111
[<Hello />, <Hello />, <Hello />];
1212

1313
data.map(x => <Hello>{x}</Hello>);
14+
15+
<Hello {...{ key: id, id, caption }} />
1416
```
1517

18+
In the last example the key is being spread, which is currently possible, but discouraged in favor of the statically provided key.
19+
1620
The following patterns are **not** considered warnings:
1721

1822
```jsx
1923
[<Hello key="first" />, <Hello key="second" />, <Hello key="third" />];
2024

2125
data.map((x, i) => <Hello key={i}>{x}</Hello>);
26+
27+
<Hello key={id} {...{ id, caption }} />
2228
```
2329

2430
## When not to use

0 commit comments

Comments
 (0)