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?