JedWatson / react-select

The Select Component for React.js
https://react-select.com/
MIT License
27.42k stars 4.1k forks source link

OptionType doesn't describe what it accepts #5894

Open tswaters opened 2 months ago

tswaters commented 2 months ago

This is more of a documentation bug than anything else, although maybe there's a bug in here somewhere. This shows up in the "OptionType":

type OptionType = { [string]: any }

Which is a pojo, anything goes. And while you can provide any object, I found there was some weirdness.

When I used the select with an array of objects looking like {id, name}, after I selected an option every option turned blue... Once I refreshed the page, it would go back to normal. I'm using HMR so needed to refresh the page a lot.

It look me a while to figure out how to keep the menu open, then that the applied classes on my blue entries correspond to something being selected -- so selecting one item selected all of them? Weird.

Looking through some of the examples that people have used, I started passing {label, value} in addition to custom properties and sure enough, once value was present, the issue went away.

Seems to me the type for OptionType should explicitly list value if it's required for functionality.