select icon indicating copy to clipboard operation
select copied to clipboard

Can't create a Select component with a Object value

Open RainingChain opened this issue 7 months ago • 0 comments

I'm trying to create a Select component with a object value.

{
 label: `My String`,
 value: { CuteCharm: true },
}

This results in a runtime error because value is rendered here: https://github.com/react-component/select/blob/48e24574fdf6a7b68589631e32d69d8dc629c974/src/OptionList.tsx#L309C9-L309C16

Image

Expected behaviour: value can be an object, and it is not rendered (only label is rendered).

Proposed solution: Replace {value} by {typeof value === 'object' ? value.toString() : value}

RainingChain avatar Jul 29 '25 16:07 RainingChain