React-select: Any way I can set maxlength when searching?

Created on 27 Apr 2018  路  3Comments  路  Source: JedWatson/react-select

I tried asking this on stackoverflow as suggested here, but there's no response so far: https://stackoverflow.com/questions/49242789/does-react-select-support-maxlength-in-search.

Is this simple enough that I could code it myself if pointed in the right direction?

thanks

Most helpful comment

this is how you can apply maxLength

pass maxLength as a props or define in your file

<Select
...
onInputChange={inputValue =>
            (inputValue.length <= maxLength ? inputValue : inputValue.substr(0, maxLength))
          }
....
/>

All 3 comments

Thanks for using StackOverflow first, we appreciate it. Glad you found the solution, and answered for the next person 馃檪

any solution for v2, inputProps has been removed from props of react-select.

this is how you can apply maxLength

pass maxLength as a props or define in your file

<Select
...
onInputChange={inputValue =>
            (inputValue.length <= maxLength ? inputValue : inputValue.substr(0, maxLength))
          }
....
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

coder-guy22296 picture coder-guy22296  路  3Comments

steida picture steida  路  3Comments

MindRave picture MindRave  路  3Comments

brunocramos picture brunocramos  路  3Comments

MalcolmDwyer picture MalcolmDwyer  路  3Comments