Searching is one of the most important components of your web application. Let's take an example of an E-commerce platform where there are thousand...
For further actions, you may consider blocking this person and/or reporting abuse
Nice tutorial :) One comment - you don't really need to set the filtered results on the state in this case. I'd just filter the people according to the search term during render:
Here's a sandbox.
Thank you, that was really helpful! One quastion: do you know how to make the search accept two seach parameters? like i want to search base on the name and also the address?
This what i tried, and failed :(
I think it'd be
const results = !searchTerm && !searchTerm2instead of||otherwise the filtering will be applied only of both search terms are present.i came up with this solution and it works now but only if one of the conditions is true. I want to make the method filter the two conditions in the same time. So like i want to know all the people that their name is Alex and lives in New york
For your specific case you can do like this:
However, note that the filter won't be applied unless both search terms are present.
Yah but that is exactly what i don't want. I want that the user can choose one of the filters or both of them in the sametime
call data from api and filter ....
codesandbox.io/s/unruffled-bose-tk...
Please Help Me .. See my Code
The problem is when I search in the search field to my note app its work but when I remove search field text my old add data not show only search data show see my code you better understand that what I m trying to say
Thanks. I tried you exact code and get this warning:
29:6 warning React Hook useEffect has a missing dependency: 'filtered'. Either include it or remove the dependency array react-hooks/exhaustive-deps
Any suggestions?
My search isn't working
Actually, the search is working. I didn't realize that I had to type lower case. Can that be removed? Most people will start typing names in upper case (at least the first letter).
Excellent!
thanks a lot !! you made my day..
Great.
One nitpick here: Make sure you trim your string for searching. Trim removes all the spaces at the start and end of the string.
The cover photo looks like the macbook has tin worm 🐛
🤣🤣 Actually i got the picture from unsplash
Okay well whoever took it, they must have been worried about yin worm 😁
This is great for simple arrays, but what about arrays of objects and you want the search to be broader in scope. For instance if you want to search a fitness class (which is an object) by name, or by duration, or by intensity or any other property
How do I change the code if I want people to display as a list by default, without typing something in the searchbox?
Has anyone built a search app that has a form that the user submits and then display the results?
Search only starts with a small letter. It doesn't work with the big one
Hi, thank you for this post, it was very helpful. I was wondering, is there a way to make the list hidden, and only show when the user is actually searching?
Thx bro
when i try to use this code to filter i m facing this kind of error again and again please help
TypeError: oldData.toLowerCase is not a function
Great post
Hi!
What If I have in a separated component the Search Bar from the list of results? I want to know how can I send the results to a parent component :)
Thanks for this!
helpful, thanks.
Love it ! Simple and easy to follow. Thanks alot
Such a detailed post! helped a lot to understand hooks. Much appreciated.
It was realy helpful, thanks!
Maybe somebody know how to implement a feature which would highlight the searched results in the list?
thanks bro