React & Next.js errors · Error 03 of 7

“Each child in a list should have a unique key prop”

By Muhammad Abdullah, full-stack, mobile and ai automation developer · Last reviewed

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

Short answer

Items rendered with .map() need a stable, unique key so React can track them. Use an id from your data; avoid array indexes when items can be added, removed or reordered.

Common causes

  • Missing key on the element returned from .map().
  • Keys that repeat, such as names or titles.

How to fix it

  1. Use a stable id on the outermost element of each item:

                          {users.map((user) => (
      <UserRow key={user.id} user={user} />
    ))}
                        

Let’s talk about the next step

Have an idea, a stuck app, or a workflow toimprove?

Tell me what you are building, what is blocking you, and what a successful outcome looks like.