index as key
Using an item position in an array as its React key, which breaks when items are inserted, deleted or reordered.
In more detail
After an insertion every later item gets a different index, so React attaches the old state and DOM nodes to the wrong items and typed text appears in the wrong row. Index keys are only safe for lists that never change order. Leaving keys out has the same effect, because React then matches by position.
Related terms
- key (React) — A special string or number you give to elements in a list so React can tell which item is which between renders.
- component identity — How React decides that a component in the new render is the same one as before, so it keeps its state.
Taught in
- Keys In Depth: Identity Preservation And Identity Resetting — React 19 & Modern Component Architecture