Search Filter in React JS with Search Bar in React Example

  Рет қаралды 65,100

Dave Gray

Dave Gray

Күн бұрын

Пікірлер: 110
@bkatsevych
@bkatsevych 2 жыл бұрын
That's exactly what I've been looking for! Thank you a lot!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad I could help, Bohdan!
@ariffaysal9458
@ariffaysal9458 2 жыл бұрын
thanks for the clear description with clean react code. learning so much from you! 👍
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@gokulpradap
@gokulpradap 2 жыл бұрын
Hi brother you're so great please use try catch instead of .then catch thankyou
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Both work. I often use try/catch with async/await code. Sometimes I use thenables but not often.
@gokulpradap
@gokulpradap 2 жыл бұрын
@@DaveGrayTeachesCode thankyou so much
@nicholasbrown4372
@nicholasbrown4372 2 жыл бұрын
Great job Dave! Keep it up with these key React functionalities. I have a personal request. I would like you to make a video on Master-Detail pattern. Thanks
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome, Nicholas, and thank you for the request! 💯
@ricktheobserver8113
@ricktheobserver8113 2 жыл бұрын
wonderful, awesome tut. Big thanks!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@islombekdev
@islombekdev 2 жыл бұрын
Thanks Dave! Your videos so helpful.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@andresbreuer
@andresbreuer 2 жыл бұрын
Thanks again Dave!!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome, Andres!
@Zzyzx-
@Zzyzx- Жыл бұрын
Can you make the same tutorial using TypeScript for us?:)
@Alias_s
@Alias_s 7 ай бұрын
Why doesn't anyone explain how to achieve the same result when we obtain data by clicking the search button?
@rahulghosh7608
@rahulghosh7608 Жыл бұрын
when i search something and there is no result i simply tap on back space. But the catch is when i tap on back space button its not updating. Link i search something "s" and there is 4 results after that when i type "sh" then there is no results and its totally fine but when i cut the "h" and there is only "s" in search input but it still showing 0 results
@tacosdesuadero4875
@tacosdesuadero4875 2 жыл бұрын
wonderful tutorial, I thought it'd be more difficult to build but it really was quite simple, thanks
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad it helped!
@elab4d140
@elab4d140 2 жыл бұрын
great tutorial, you can make the input value debounced, so that you wont make an api call every time you change the input
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
That works if the search input creates a new request every time it changes. That is not what this tutorial does. This example loads all posts (or products or todos or whatever the content may be) as the initial state, and then it filters that state content in the frontend. What you are describing would be a frontend that sends a request to the backend REST API that contains a query parameter. The filtering would then happen in the backend and the results would be sent back. In that case, debouncing would be a GREAT idea. 🚀
@Bioed-n4c
@Bioed-n4c 2 жыл бұрын
How do we do that
@ernestechie
@ernestechie Жыл бұрын
@@Bioed-n4che has a tutorial on that
@ernestechie
@ernestechie Жыл бұрын
@@Bioed-n4c kzbin.info/www/bejne/g3nQXmWPorx4m80si=7XRxwxCSUssF31hF
@FundoGenshin
@FundoGenshin 3 ай бұрын
Did you get the data from api or json from your own project?
@nicholasbrown7016
@nicholasbrown7016 2 жыл бұрын
Hey Dave, I would like you to make a video on React.js file uploader of all file types and also an emoji picker. :)
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you for the requests!
@hardwired66
@hardwired66 2 жыл бұрын
Thank you sirr
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@bryandelacruz9066
@bryandelacruz9066 6 ай бұрын
Hi, is the search button clickable? thanks
@siddiqahmed3274
@siddiqahmed3274 2 жыл бұрын
Sir, why didn't you perform setPosts and setSearchResults in same then function?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Good catch, Siddiq! I don't use thenables that often in preference of async / await, but here I was simply thinking of one thing at a time. You are correct in thinking React will simply batch the state updates and they could both be in the first thenable without the need of the 2nd .then() 💯
@blackpurple9163
@blackpurple9163 Жыл бұрын
Why did you not use input type=search instead? I believe that's the exact reason that component was made for Btw if we were to highlight the matching text in resultant posts, how do we implement that?
@alexotoous
@alexotoous Жыл бұрын
Optional chaining (?.) was crushing the app so I removed it.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Hard to imagine that optional chaining has a big impact in a small example like this. Worth a read: blog.allegro.tech/2019/11/performance-of-javascript-optional-chaining.html ..."If your project contains much more optional chaining occurrences, like ten thousand, or you run the code on very slow devices - it might matter. Otherwise, well, it’s probably not worth bothering about."
@simonedwards7101
@simonedwards7101 2 жыл бұрын
I've just created one of these myself. I wonder how different the code will be 🙂 (Dave the Pro, Simon the Newbie). Will update you later.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
I'm expecting yours to be better, Simon - as all teachers should! 😃 For example, you could make yours case-insentive while my example is not. 🚀
@simonedwards7101
@simonedwards7101 2 жыл бұрын
@@DaveGrayTeachesCode I did indeed have a case insensitive search. I also took the useEffect route like you mentioned in the video. In addition to the search input field I used a dropdown select to filter on topics / tags. And finally I used fetch to bring in some static json from an Azure cdn instead of using Axios. Thanks Dave for the content. I remember when this stuff was alien to me. 20+ years working in infrastructure now attempting to be proficient in code 🤣
@mileadavid7007
@mileadavid7007 Жыл бұрын
Do you know what should I change to see all the data from the API when not searching?
@mhdfirassbarakat6587
@mhdfirassbarakat6587 Жыл бұрын
Great Content Dave Keep Going, Master 😊
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you 🙌
@andrewaghoghovwia1948
@andrewaghoghovwia1948 2 жыл бұрын
Great content. Absolutely what I needed!!!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Glad it was helpful!
@codingispower1816
@codingispower1816 10 ай бұрын
Is there a difference between attribute and attribute? Attribute and attribute are spelled identically but are pronounced differently and have different meanings, which makes them heteronyms. To attrib-ute is a verb so to give credit to someone for something. (verb) Attribute is a characteristic of something (a noun).
@DaveGrayTeachesCode
@DaveGrayTeachesCode 10 ай бұрын
Yes I think I have pronounced this incorrectly at times. Hopefully everyone knows what I mean.
@codingispower1816
@codingispower1816 10 ай бұрын
Oh yeah of course. I'm sure. Thanks for all you do, Dave! Your videos are helping me to prepare for some upcoming react based interviews!@@DaveGrayTeachesCode
@phongdautranle9911
@phongdautranle9911 Жыл бұрын
Hi Dave, I recently follow your video course MERN stack app. And I am trying to apply notes filter by the way you show in this video, and seem not working. Do you have any other dea to apply filter
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
This is the approach / concept I would use.
@phongdautranle9911
@phongdautranle9911 Жыл бұрын
Thank you!
@KellenBegin
@KellenBegin 2 жыл бұрын
Great react tutorial! The word attribute is one of those words (like contract) in which emphasis/accent changes depending on the part of speech being used. Accenting the 'a' is a noun and accenting the 'i' is a verb.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you, Kellen! Yes, my Kansan way of pronouncing a few things doesn't always mix with the rest of the world 😅 I keep trying!
@mentoriii3475
@mentoriii3475 Жыл бұрын
Hey Dave, good implementation, I would like for you to review my implementation with redux toolkit as following: make a posts state in slice -> fetch initial posts from an api where you get all posts, have a secondary api to fetch only searched posts with &search={input} -> and in the parent component have a useeffect where if searchbar.length === 0 dispatch the getAllPosts api result else if search input length > 0 dispatch the getPost api results, while the results of both api calls get stored in initial state which was posts:[ ] and overwrite each other, I think your implementation is better, I had problems implementing pagination if i keep overwriting results of both api's
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Easier to post code snippets on my Discord: discord.gg/neKghyefqh
@regilearn2138
@regilearn2138 2 жыл бұрын
Awesome superb, and Dave once we fetch the data using redux , or component state will not available after the page refresh, in order to keep data(persist data) during page refresh, what is the recommend way, Please let me know your thought.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You are correct. Refreshing a web app is just like reloading a program. When using Redux, there is an npm package called Redux-Persist: www.npmjs.com/package/redux-persist - I think it uses localStorage so I wouldn't use it with anything like passwords or web tokens though.
@Roronoa1062
@Roronoa1062 Жыл бұрын
Great tutorial, but I have these questions : what if I don't wanna use onChange function, rather I would want to use event listener to handle the onChange event [ I was not using form (I was just having a input tag and a button), so I guess using form would resolve the issue where I have to take two function onChange & onClick to register the input and click respectively]. And secondly using onChange is a good practice or not in terms of vulnerability.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
I think you answered your first question, but you can handle single change events or gather all input info from a form submit event. I recommend controlled inputs in React vs using an event listener as with Vanilla JS. 2nd question - Nothing wrong with an onChange in React. They are used all the time.
@SVAMYIYA
@SVAMYIYA 2 жыл бұрын
What to do if npm doesn't work because Node.js is not supported on Windows 7? Why didn't you say anything about this?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Microsoft already declared Windows 7 end of life: www.google.com/search?q=windows+7+end+of+life And I cannot comment on every possible operating system. That said, this Stackoverflow answer may help you: stackoverflow.com/questions/62212754/latest-nodejs-compatible-with-windows-7 If not, it is high time to upgrade from Windows 7.
@SVAMYIYA
@SVAMYIYA 2 жыл бұрын
@@DaveGrayTeachesCode Sorry, but can search be implemented using CDN by connecting React?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
@@SVAMYIYA a React app can use a CDN. The API data will come straight from a server.
@gmjitendra
@gmjitendra Жыл бұрын
Very nice Dave. My personal recommendation if you can cover test cases as well :)
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Absolutely! This request is on my list - thanks!
@egajelic
@egajelic 2 жыл бұрын
Hi dav, any plan to make typescript crashcourse or series?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Yes, Typescript series coming soon!
@egajelic
@egajelic 2 жыл бұрын
awesome !
@rolibernanda3660
@rolibernanda3660 2 жыл бұрын
Great my man Why did you use chain promise instead of just use setSearchResults and setPosts in the same .then block?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you 🙏 and good question that I believe Siddiq also asked. It is not needed. Too often I get caught up in "teacher mode" and give implicit instructions like do this, then this, then this. When I'm coding and not teaching, I try to be more declarative. This was part was overly implicit.
@aymenbachiri-yh2hd
@aymenbachiri-yh2hd 6 ай бұрын
thank you
@AveN7ers
@AveN7ers 2 жыл бұрын
Easy enough but is filtering in the frontend something that's done in the real world or do they send a request to the backend database?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Both. Depends on the situation.
@metadance3028
@metadance3028 2 жыл бұрын
I really wating for a new course from you about typescript and CI/CD concepts, all your tutorials helpful to much. Thank you a lot.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you! 💯
@Sudhentertainment
@Sudhentertainment 2 жыл бұрын
great dave make such short videos with specific react features. Thst will be very great
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you! 💯
@IsraelMendoza-OOOOOOO
@IsraelMendoza-OOOOOOO Жыл бұрын
👍
@P3truts
@P3truts Жыл бұрын
Finally a good searchBar example. Most use/show the searchBar as being the only component that filters through data.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you! 💯
@wesleyowen904
@wesleyowen904 2 жыл бұрын
I like your videos and was wondering if you could do a project with flutter front and back end?
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you, Wesley! I have not yet gotten into Flutter, but I've heard good things!
@biLLie_wiLLie
@biLLie_wiLLie Жыл бұрын
It would be great from you to show how to search, filter and highlight results of posts from api. Thank you!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you for the request!
@DineshVutukuru
@DineshVutukuru 2 жыл бұрын
Please make tutorials for unit testing and redux connect as well.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you for the requests!
@deekshithpv4327
@deekshithpv4327 2 жыл бұрын
Thank you Dave! I just wanted to say thank you! I just had to! :D
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome! 🙏💯
@ashutoshtripathi8257
@ashutoshtripathi8257 2 жыл бұрын
Hello sir, can you start interview series for reactjs
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
I've got a few other topics planned first, but I'll add this request to the list! 💯
@ateebasif5360
@ateebasif5360 2 жыл бұрын
Hey can you please do this with a table pagination where we can go to next page and when we search we get the searched results with the pagination
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
To do this, we would query a REST API that allows for search parameters and provides paginated results. After receiving the results, we could provide use pagination on the front end or infinite scroll - I have tutorials on both of those in this same playlist. Thanks for the request!
@ateebasif5360
@ateebasif5360 2 жыл бұрын
@@DaveGrayTeachesCode thank you so much for your reply i found that video you mentioned and your content it's really helpful.
@hassamulhaq7762
@hassamulhaq7762 2 жыл бұрын
Teaching method is really awesome. you explain the functionality plus take care how to manage components. Dave i have a query, I'm using Laravel for backed and from last month i start learning react. One thing i notice in node/express we need to write raw MySQL queries but in laravel we have Eloquent ORM, and in PHP we have propel_orm using these our work will be easy. As I'm beginner in node, express is there any easy way to write sql queries.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
There are several available, but the most popular ORM is Sequelize: www.npmjs.com/package/sequelize
@hassamulhaq7762
@hassamulhaq7762 2 жыл бұрын
@@DaveGrayTeachesCode thank you 🖤
@OneworldKW
@OneworldKW 2 жыл бұрын
Great video. I like the way you explain things.
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you for the kind words! 🙏
@hussenelswaf9660
@hussenelswaf9660 Жыл бұрын
Great content. Absolutely what I needed!!!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Glad it helped!
@Собственник-т3к
@Собственник-т3к Жыл бұрын
Thanks
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Welcome!
@mtpk0
@mtpk0 2 жыл бұрын
😎
@sonamohialdin3376
@sonamohialdin3376 2 жыл бұрын
Awesome tutorial thank you
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
You're welcome!
@dharmeshgohil9375
@dharmeshgohil9375 2 жыл бұрын
Nice
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thank you!
@ricktheobserver8113
@ricktheobserver8113 2 жыл бұрын
Hello Dave, quick question, instead of passing props to give App.js the resultArray, can you teach us doing it using Redux and RTK. Love you!
@DaveGrayTeachesCode
@DaveGrayTeachesCode 2 жыл бұрын
Thanks for the love and request!
@ucNguyen-qz2lf
@ucNguyen-qz2lf Жыл бұрын
High quality tutorial as usual. Thanks Dave!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
How to Use a Single Function to Manage React Form State
14:23
Dave Gray
Рет қаралды 13 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 478 М.
Search Filter in React JS - Filter Through Results
8:53
Code Commerce
Рет қаралды 155 М.
Pagination in React Tutorial with React Query, Hooks Examples
22:50
Search Bar in React Tutorial - Cool Search Filter Tutorial
31:53
React visually explained: 'use client'
15:57
Delba
Рет қаралды 37 М.
How To Create A Search Bar In JavaScript
14:28
Web Dev Simplified
Рет қаралды 412 М.
Make a Search Bar with React (with API Calls) | Beginners Tutorial
27:49
Most Beginner React Developers Do This Wrong
13:47
Web Dev Simplified
Рет қаралды 233 М.
React Search Filter Tutorial Beginner to Advanced
26:50
Lama Dev
Рет қаралды 263 М.
Infinite Scroll in React | Full Tutorial
38:53
Dave Gray
Рет қаралды 50 М.