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

Taught in

References