When working with any type of list in React, you will often encounter this warning if you forgot to include a key prop: Warning: Each child in a list should have a unique “key” prop So, why does React tell you to include keys and why is it important...

Markdown supported · ⌘↵ to post
Excellent writeup on the importance of key in React. However, are you sure the diffing is done on the virtual DOM and real DOM? To my understanding, the reconciliation happens between the most recent virtual DOM tree and the previous tree.
So true! Recently I had a requirement to refresh a component, I initially thought of creating a state variable and refresh it based on that but adding a key solved the issue. I was looking for an article to explain "behind the scenes" and I landed here... Thank you so much for explaining! :)
Interesting. I did not know about that. I never came across that.
So from what I understand, react does not re-render the input field when using index. That's why there is this issue. Am I right?
Linus Närkling
Sometimes I do things
Is the "key" attribute special or does React look for any attribute? I have a list of divs where the "title" attribute uniquely identifies the object - will that work just as well?