tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.com
MIT License
676 stars 147 forks source link

Got error when using number as value #66

Closed KienPM closed 4 years ago

KienPM commented 4 years ago

I got this error when using number as value

Uncaught TypeError: this.state.value.slice is not a function
    at SelectSearch.chooseOption (index.js:509)
    at onClick (index.js:670)

I think this line cause the error

var currentValue = this.state.value.slice();

Hope that you can update it! Thank you so much!

matheusrgarcia commented 4 years ago

yeah, had to use toString() to handle that.

tbleckert commented 4 years ago

Using anything other than strings should result in a warning in dev mode because of https://github.com/tbleckert/react-select-search/blob/master/src/types.js#L5 .

But yeah, I agree. We should definitely handle both strings and numbers. I'll make a patch during the week if no one beats me to it.

tbleckert commented 4 years ago

Fixed in 2.0.5

vvo commented 4 years ago

Hey there, just confirming that I tested the new fix and it's working well, thanks a lot!