Skip to content

fix: use stable keys in InfoGrid - #112

Open
kavgupt wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
kavgupt:fix/info-grid-keys
Open

fix: use stable keys in InfoGrid#112
kavgupt wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
kavgupt:fix/info-grid-keys

Conversation

@kavgupt

@kavgupt kavgupt commented Aug 30, 2026

Copy link
Copy Markdown

The InfoGrid component uses array index as the React key for its items. This is fragile when items can be reordered, inserted, or deleted -- React will reuse DOM nodes incorrectly, leading to stale content or misplaced focus.

Since each item has a label field that is unique within a grid, using item.label as the key gives React a stable identity for each row.

Change: Replaced key={index} with key={item.label} and removed the unused index parameter from the map callback.

This is a one-line semantic improvement -- no visual change, but correct behavior when the items array changes between renders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant