react-select-show label + value when a label is selected from dropdown

3.2k Views Asked by At

I have a use case in my UI where for react-select component I want to show label in the dropdown but when we select the label, the selected option shown should be label + value. How can I implement this?

1

There are 1 best solutions below

0
On

Use the formatOptionLabel prop to create your layout for your 'selected' option (the display in the search field), but use a custom Option layout for the display of your 'option's (or, conversely, use the prop to create your 'option' layout and provide a custom SingleValue or MultiValueLabel component for the display in the search field).

The documentation tells you how to apply custom components.