React | Lists and Keys | Question 9

Last Updated :
Discuss
Comments

What is the key used in this example?

JavaScript
const users = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}];
return (
    <ul>
        {users.map(user => <li key={user.id}>{user.name}</li>)}
    </ul>
);

user.name

user

user.id

index

Share your thoughts in the comments