Skip to content

Can't create a Select component with a Object value #1159

Description

@RainingChain

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions