react-select icon indicating copy to clipboard operation
react-select copied to clipboard

true/false values is not working

Open sobrinho opened this issue 11 years ago • 10 comments

<Select value={true} options=[{value: true, label: "Yes"}, {value: false, label: "No"}] />
<Select value={false} options=[{value: true, label: "Yes"}, {value: false, label: "No"}] />

In both cases the option isn't selected. Using string like "true" and "false" make it works.

Isn't allowed to use boolean values?

sobrinho avatar Oct 29 '15 21:10 sobrinho

+1 I've run into this same issue as well. @JedWatson is this something the component should support?

joefiorini avatar Jan 04 '16 17:01 joefiorini

+1

592da avatar Apr 25 '16 10:04 592da

+1, just running into this issue...

adamaoc avatar May 10 '16 16:05 adamaoc

Someone ? :octopus:

592da avatar May 18 '16 11:05 592da

+1; having same issue.

jeremym avatar Jul 12 '16 17:07 jeremym

Is there a plan to support this anytime soon?

ktalebian avatar Aug 08 '16 21:08 ktalebian

I found:

https://github.com/JedWatson/react-select/blob/17d76a4161096cb88fb04a6e9e6529580e67b305/src/Select.js#L564

which essentially restricts values to strings and numbers. If I change that line to:

if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') return value;

...then booleans seem to work fine.

Aaronius avatar Sep 16 '16 19:09 Aaronius

Hello, I am observing this issue again.. value gets selected just fine if value is true. but value is not selected when value is false. const OptionValues = [ {value: true, label: 'Yes'}, {value: false, label: 'No'} ];

I am @^1.0.0-rc.10

swp44744 avatar Oct 14 '17 20:10 swp44744

forgive me for false alarm.. It was my mistake... i was checking if value is not selected then set default value. and i was doing that by - !value ? defaultValue : value. so whenever value is false it was trying to set it to default value and for that dropdown default value was " ".

swp44744 avatar Oct 14 '17 21:10 swp44744

onChange={e=> setFavorite(JSON.parse(e.target.value))} return true value

Pawankashap avatar Jun 28 '23 08:06 Pawankashap