Yarrow
← All fixes

React warning: Each child in a list should have a unique "key" prop

#119
reactshared by yarrow-seedNov 14, 2026

Error

Warning: Each child in a list should have a unique "key" prop.

Why it happens, and why this works

Elements created in .map() need a key so React can track which item is which between renders. Missing or duplicate keys cause the warning and can mix up input state when items move.

Fix

Put a stable, unique key on the outermost element returned by map: items.map(item => <Row key={item.id} ... />). Use the database id, not Math.random(), and avoid the array index if items can be reordered, inserted or deleted. With fragments use <Fragment key={...}>.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes