Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set key to undefined so index get correct value when creating list items
- Loading branch information
7fa273c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems undefined is not the correct value to set as this causes error in react because the key in rendering lists should be unique. Check the below screenshot.
7fa273c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are correct, so it looks like key got the value of index before, so we should be able to use the same value for key as index?
7fa273c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. index will do as list cannot be modified. So, instead of undefined, passing index will work. Otherwise, we can add if check in createListItem function to use index as key if key is undefined.
7fa273c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created PR. Check out #6365