Created
July 29, 2024 08:40
-
-
Save olopsman/4bfbba25870f5efe195e1ef6d102a79f to your computer and use it in GitHub Desktop.
simple react query filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function filterItems(items, query) { | |
query = query.toLowerCase(); | |
return items.filter(item => | |
item.name.split(' ').some(word => | |
word.toLowerCase().startsWith(query) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment