#Select onChange arguments

7 messages · Page 1 of 1 (latest)

sudden shuttle
#

Can someone explain the <Select /> component onChange arguments?

The value argument is string | null but the option argument, option.value is just string. It's confusing because the string | null would imply that it's sometimes not a string and you need to check for that, but if option.value is always a string, it makes me second guess.

Anyone understand this?

toxic shale
#

It’s null when you clear the value or deselect it (with the clearable prop and the allowDeselect prop)

sudden shuttle
#

in that case though, what would the option argument be?

toxic shale
#

Well that’s exactly the point : when the value is null, it means it maps to no provided option

#

Ah I see what you mean, it’s about the second option newly added to the callback. I guess it’s undefined in this case, even though it’s not reflected in the typing

#

Looking at the code, both arguments are null if the first is null

sudden shuttle
#

I think there should be a nuace to these types if the allowDeselect prop is true, then onChange value should just be string not string | null.