[guide] [react] Explain use of ID over key right on page

This commit is contained in:
Kevin Weber
2018-08-26 17:41:01 -07:00
committed by Jordan Harband
parent 5443d03de2
commit 48448a81cc

View File

@@ -351,7 +351,11 @@ This style guide is mostly based on the standards that are currently prevalent i
<div />
```
- Avoid using an array index as `key` prop, prefer a unique ID. ([why?](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318))
- Avoid using an array index as `key` prop, prefer a stable ID.
> Why? Not using a stable ID [is an anti-pattern](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318) because it can negatively impact performance and cause issues with component state.
We dont recommend using indexes for keys if the order of items may change.
```jsx
// bad