JedWatson / react-select

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

Suggestion: If value and label are "undefined" The current select value should display "Select" placeholder instead of being empty box #5665

Closed AsLi-IN closed 1 year ago

AsLi-IN commented 1 year ago

If value and label is undefined i.e <Select value:{{value: undefined, label: undefined}} it should display the "Select" placeholder instead of making it empty box.

ebonow commented 1 year ago

Strongly disagree.

A badly formed object doesn't equal undefined. IMO, the developer own the options (and the capability to define how new ones are created) and thus it's their responsibility to make sure they are properly mapped. Plus, this seems easy enough to resolve.

const sanitizedOptions = options.filter(o => o?.value !== undefined)

return <Select options={sanitizedOptions} />

Closing this issue but can reopen if there is any compelling arguments otherwise.