I am aware that I should not use the index as a key when mapping an array in react. Consensus seems to be to use something particular to that index as a key. My question is what do you normally use? Is it better to do something like this or is it no different to just using the index when you are mapping?
const usersWithId = users.results.map((user, index) => {
return (
{...user, id: index}
)
})
{usersWithId.map((user) => {
return (
<p key={user.id}>{user.id}</p>
)
})}
vs just using it with the index
{users.map((user, index) => {
return (
<p key={index}>{user.id}</p>
)
})}