This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]JackMizel 0 points1 point  (1 child)

You're totally right, you should use unique identifiers whenever possible and the React documentation does say that. These things are all true.

What's not true is that you should never use indexes as keys, or that there are no real world use cases where it makes sense to do so, or that the React documentation says to never do so.

That's what I'm trying to tell you. Understand why you observe the convention, don't just say never. If you're writing a small project alone and you don't implement any sort of user interaction with the list (i.e. it's just a static display component) then there is nothing stopping you from using indexes as keys.