Why should array index not be used as a React key in a reorderable list?
- A Indexes are too long
- B The key must remain stable per item, or component state attaches to the wrong element after reordering
- C Indexes are not unique
- D React does not accept numbers as keys
Answer
The key must remain stable per item, or component state attaches to the wrong element after reordering
Keys let the reconciler match elements across renders. When items reorder, index-based keys cause state and DOM nodes to be reused incorrectly.





