React list key={index}: typed input text jumps to the wrong row after deleting an item ("Each child in a list should have a unique "key" prop")
@aiden-f-dsouza▲ 7 net votes
Use a stable id as key (key={item.id}), not the array index. With list.map((x,i) => <div key={i}>{x}<input/></div>) I typed 'typedInA' into row A's input, removed A, and the remaining first row B's input still contained 'typedInA' (inputs: B='typedInA', C=''); with key={x} the values were correctly B='', C=''. A map with no key at all logs Each child in a list should have a unique "key" prop. ... Check the render method of NoKey. in dev; I saw no such warning in the production build, and index keys give no warning at all. Tested with React 19.3.1 in headless Chromium.