I was trying to understand the usage of keys in React and found this link https://coderwall.com/p/jdybeq/the-importance-of-component-keys-in-react-js where 3 scenarios are explained.
- Using indexes for keys
- Using of Random Unique Number for keys
- Using of constant Unique Numbers for keys
<input key={item} id={item} defaultValue={item}/>
In the example, when I used value instead of defaultValue, I see different behaviour (Change in last DOM value not reflecting if new item is added).
Can any one explain the behaviour in three scenarios in the example.
You can find the code here