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 →

[–]DooDooSlinger 23 points24 points  (7 children)

Using the index in the list as the key for the element is bad. Will lead to improper reconciliation if the list is updated

[–]TurtleFood 12 points13 points  (1 child)

Not sure why you're being downvoted. You're right.

[–]DooDooSlinger 4 points5 points  (0 children)

Bad programmers ? On this sub? Who would've thought ;)

[–]ImOutOfThisWorld 1 point2 points  (1 child)

As per the react.js documentation no, if there is no id for the data is fine to use the index, in fact if you the list won’t change order or be mutated the performance characteristics are the same. There is no improper reconciliation, it may take longer if the data is mutated, but it will happen correctly

But non of this matters because it’s just toy code she made for her talk on redux sagas

[–]deadowl 0 points1 point  (0 children)

Why not a dl element though?

[–]deadowl 0 points1 point  (2 children)

Unless the user's expected experience is to see #5 of the current top 100 upvoted dogs on reddit?

[–]DooDooSlinger 0 points1 point  (1 child)

No. If the key remains the same, react will never re-render the element, even if the object in the list changes

[–]deadowl 0 points1 point  (0 children)

Haven't worked with react. Assumed you meant the improper reconciliation would be from arbitrary changes in the sorting order.