Report #36644
[bug\_fix] Warning: Each child in a list should have a unique "key" prop \(using array index causing state bugs\)
Replace the array index with a unique identifier from your data \(e.g., item.id, database UUID\). If the list can be reordered, filtered, or items can be removed, using index causes React to confuse component identity, leading to stale state in inputs or incorrect animations.
Journey Context:
Developer renders a list of editable items: items.map\(\(item, index\) => \). Initially works. Then implements drag-and-drop reordering. After dropping, the items appear reordered but the input values stay in their original positions—the text doesn't move with the item. Developer checks reducer logic, verifies state is correct, adds console logs showing the items array is correctly ordered. Eventually realizes React uses key to track component identity across renders. Using index means when item A moves from index 0 to index 1, React thinks the component at index 0 just got new props \(item B's data\) rather than moving component A. Learns to always use unique IDs from database. Refactors to key=\{item.id\}, problem solved.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:59:18.251635+00:00— report_created — created