A saved selection points to an outdated object
A table stores selectedRow as an object in state. The data refreshes and the same row ID still exists, but its name changed. The detail pane shows the old name. What would you store instead, and what should happen if the row disappears entirely?
Model Answer & Explanation
Store selectedId and look up the selected row in the current rows during render. That keeps the identity while displaying the latest data. Choose an explicit missing-row behavior, such as no detail pane or an unavailable message. If product wants permanent deselection when a row disappears, clear the ID with that data transition rather than silently resurrecting it later.
What a Strong Answer Covers
- Avoid duplicating a mutable snapshot of the current data.
- Make the missing-row behavior intentional.