On page https://reactjs.org/docs/reconciliation.html
it is said that
Here is an example of the issues that can be caused by using indexes as keys on CodePen
How can the issue be created? I added record to the front, to the back, and sort them, and they seemed to work ok?
Actually, here is a simple case and I can't break it: https://stackoverflow.com/questions/60283967/in-reactjs-using-array-index-as-key-is-said-to-not-work-well-but-i-cant-make
I can only break it if it is all 3 conditions:
It has to be function component using useState, and I have to mutate the state (which the docs says I shouldn't do), and use index as key. So if I don't mutate the state, I can't make it not work well if I use index as key.
On page https://reactjs.org/docs/reconciliation.html
it is said that
How can the issue be created? I added record to the front, to the back, and sort them, and they seemed to work ok?
Actually, here is a simple case and I can't break it: https://stackoverflow.com/questions/60283967/in-reactjs-using-array-index-as-key-is-said-to-not-work-well-but-i-cant-make
I can only break it if it is all 3 conditions:
It has to be function component using useState, and I have to mutate the state (which the docs says I shouldn't do), and use index as key. So if I don't mutate the state, I can't make it not work well if I use index as key.