Skip to content

Commit

Permalink
Added key object spread example
Browse files Browse the repository at this point in the history
Spreaded key is discouraged and currently triggering the rule. Added some clarification to the doc.

Resolves jsx-eslint#1753.
  • Loading branch information
awthwathje committed Apr 3, 2018
1 parent 9346eb8 commit f128396
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/rules/jsx-key.md
Expand Up @@ -11,14 +11,20 @@ The following patterns are considered warnings:
[<Hello />, <Hello />, <Hello />];

data.map(x => <Hello>{x}</Hello>);

<Hello {...{ key: id, id, caption }} />
```

In the last example the key is being spread, which is currently possible, but discouraged in favor of the statically provided key.

The following patterns are **not** considered warnings:

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

data.map((x, i) => <Hello key={i}>{x}</Hello>);

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

## When not to use
Expand Down

0 comments on commit f128396

Please sign in to comment.