Filter data using the first character that user types in the input box #4536
-
I want to filter the data when user types the first character in the input box. Let say, the list is showing data like Andhrapradesh, Arunachal, Bihar, Boland, Bolivia, West Bengal, West Virginia. Now when user types only B, then Boland, Bolivia must be shown. Alternatively if he types W then West Bengal, West Virginia must be shown in the list. Right now I have to types 3-4 characters to get the expected result in the list. Is there any props available to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Greetings @developersatyajit It sounds like you would want to create a filter to change the logic being used for string matching. There is some documentation here, and it looks like you want to use import { createFilter }, Select from 'react-select';
const filterOption = createFilter({ matchFrom: 'start' });
return <Select filterOption={filterOption} {...otherProps} /> Please let me know if this works for you. |
Beta Was this translation helpful? Give feedback.
Greetings @developersatyajit
It sounds like you would want to create a filter to change the logic being used for string matching. There is some documentation here, and it looks like you want to use
createFilter
to change the default value ofmatchFrom
tostart
instead ofany
Please let me know if this works for you.