Warning: Each child in a list should have a unique "key" prop
Warning: Each child in a list should have a unique "key" prop.In one sentence: When you render a list with .map(), React needs a stable, unique key on each item to track them.
What it means
React uses keys to tell list items apart between renders. Without them (or with duplicates), React may reuse the wrong element, which causes bugs like inputs keeping the wrong value or animations jumping.
It's a warning, not a crash, but it's worth fixing.
Common causes
- No `key` on the top element returned from `.map()`.
- The key is on an inner element instead of the outermost one (or a Fragment needs `<Fragment key=...>`).
- Duplicate keys, e.g. using a name that isn't unique.
How to fix it
- Add `key` to the outermost element in the map, using a stable unique id from your data: `key={item.id}`.
- Avoid `Math.random()` as a key (it changes every render). Use the array index only if the list never reorders, filters, or gets inserted into.
Example
{todos.map(todo => (
<li key={todo.id}>{todo.title}</li>
))}Tried this and it's still broken? Paste your exact error for a free explanation of your specific case.
Prompt to paste into your AI tool
React warns each child in a list needs a unique key. Add a stable key from the data (like id) to the outermost element in every .map, not Math.random or index if the list can change.Still stuck?
Paste your exact error and code. Get a plain-English explanation free, or the full fix for $5.
Hitting errors every day? Builder is $15/mo for 100 fixes per month. Compare plans
Related errors
- Too many re-renders. React limits the number of renders
- ReferenceError: window is not defined (Next.js)
- useState only works in a Client Component (Next.js App Router)
- TypeScript: Property does not exist on type
Weekly: the errors breaking vibe-coded apps and how to fix them. Free.
No spam. Unsubscribe anytime.