JedWatson / react-select

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

Change `getOptionLabel` type #5633

Closed beerose closed 1 year ago

beerose commented 1 year ago

Is there a reason why a function passed to getOptionLabel has to return a string? Based on the code, it can render a React component. (I'm also using it as o => ReactElement and it works fine).

I'd be happy to send a PR that updates the types, examples, and docs.

Methuselah96 commented 1 year ago

Yes, it returns a string for accessibility reasons (so that it can be read by a screen reader).

Methuselah96 commented 1 year ago

If you would like to use a React element for the option label, take a look at the formatOptionLabel prop which is intended for this purpose.

beerose commented 1 year ago

Ok, that makes sense. Thanks!