Skip to content

How to use useState with Select? #6105

Answered by reidbarber
mattbal asked this question in Q&A
Discussion options

You must be logged in to vote
  1. items goes on Listbox instead of Select (same with the selection props). The example in the docs is a custom MySelect wrapper that sends those down to the Listbox, so I can see how that could be confusing.
  2. "Select an item" is the default placeholder (shown if no items are selected). It can be customized with the placeholder prop. This should update to your selected item once you pass selection into the Listbox, as mentioned above.

And to access the selection state from inside, you can use render props or contexts. If you do that, you don't even need to do a fully controlled version.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mattbal
Comment options

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