Report #97173
[bug\_fix] Missing or unstable key prop causing wrong state in lists
Use a stable unique identifier from the data, such as t.id, as the key; never use array index or Math.random\(\).
Journey Context:
A to-do app rendered tasks with \`\{items.map\(\(t, i\) => \)\}\`. Adding a task worked, but marking the third task complete would check the wrong item and animations broke. The developer suspected state management but the reducer was correct. The root cause is that React uses the \`key\` prop as identity during reconciliation; using the array index makes React reuse component instances by position rather than by item identity, so state inside \`Todo\` follows position, not data. The fix is to use a stable, unique identifier from the data, such as a database \`id\`, as the key: \`\{items.map\(t => \)\}\`. Avoid \`Math.random\(\)\` or \`Date.now\(\)\` because a new key on every render forces a remount. This keeps component state bound to the correct entity across reordering, deletion, and insertion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:40:30.820816+00:00— report_created — created