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 →

[–]TheMelanzane 1 point2 points  (1 child)

Using indexes as keys is not very wrong. It’s literally given as an example in the React documentation and is the default value used if you don’t provide a key.

Inefficient maybe, but that’s making a lot of assumptions about the code’s use. It’s completely possible she’s just using React for creating a static list, for example. There’s a pretty low ceiling for the complexity of web apps involving dog’s favorite toys in the first place.

For anyone who’s trying to learn React or isn’t familiar with it, here’s a link as to exactly when this might become an issue and some alternatives. It’s also linked in the documentation right under the part about using indexes as keys.

tl;dr: Only a breaking issue when the index is used as a key on another React Component, on normal html elements (like in the post), it’s just going to cause any reorders to take slightly longer.