Filtering without query an API? #176
ivanjeremic
started this conversation in
General
Replies: 1 comment
-
Hi and sorry for the late reply! You can use filterOptions prop for this. Like this: function filterOptions(options) {
// We cache the options and return a function for the actual filtering
return (q) => {
return options.find((option) => option.name === q);
};
}
<SelectSearch search filterOptions={filterOptions} .../> Your filter function is called each time the options changes and your returned function is called on input change in the search field. The filtering happens on mount/options change as well, so you can use it to limit the amount of options to display. Check this example https://react-select-search.com/?path=/story/single-select--limited-options |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a normal Array of items and I want to make the filter work, in the example filtering is done by querying an API and applying an dynamic query key, how can I make the filter work on an normal array?
Beta Was this translation helpful? Give feedback.
All reactions