You type a note in the first row of a list. Then you sort the list. The note stays in the first row, but that row now shows a different record.
This can happen when a React list uses its array index as a key. The rows look correct until someone edits a field and changes the order.
Why the text ends up in the wrong row
Each editor below stores its text with useState. React uses the key to decide which editor instance belongs to which item.
An index key identifies a position: first row, second row. After sorting, a different record can occupy that position while the editor keeps its previous state. A record ID gives React a way to match the editor to the same record after it moves.
Try the example
Paste this component into a React application's App.jsx. Start with the default stable keys, edit a note, and reverse the list.…