Skip to content

Keys vs Ids #7147

Answered by devongovett
seanrcollings asked this question in Q&A
Oct 4, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

It comes down to an implementation difference. The old collection implementation used by default in the hooks was able to use key because it walked the JSX tree. However, this implemented prevented making wrapper components as expected with React (e.g. MyListBoxItem wrapping Item). We moved to another approach that fixed this problem by letting React render as normal instead of traversing the JSX tree, but React does not pass key into components as a prop so we were forced to rename it to id.

Additionally, since ListBox and it's ilk all use id props, the names of other props like selectedKeys make a bit less sense.

Changing all of these APIs could be done, potentially in a breaking chan…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@seanrcollings
Comment options

@devongovett
Comment options

Answer selected by seanrcollings
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants