How to create Filter / search in reactjs

Manjunathkalburgi
3 min readOct 22, 2021

--

Let me tell you how to create simple filter like google in reactjs.

I have used stackblitz to react the project its pretty simple go to stackblitz and select react javascript project you will land into the react javascript project.

Once clicked react(javascript) your project folder looks like this.

Create components folder to add your components and css for holding your css.

Open App.js and edit the file.

Add following code

Let me explain you what I have did,

  1. Added BrowserRouter for Link tag and added <Router> Element
  2. Added Search component.

Part 2.

Create 2 files in components folder

  1. Search with Search.js
  2. Avatar with Avatar.js to hold user information

3.Search with search.js

Let me explain the code,

created users array to hold the users api data and player to hold the search box data.

I am using UseEffect react hook to fetch the data from API and setting up that in users array object with setUsers function.

onChange store my search parameter inside player variable with setPlayer function.

Final part to render my html and values

Final result looks like this.

https://react-d1dyj6.stackblitz.io

You can find the entire code in the below repository to use.

For any queries and help you can react me out and I can help you in solving any problem. You can provide feedback or share or donate.

Thanks for reading.

--

--

Manjunathkalburgi
Manjunathkalburgi

Written by Manjunathkalburgi

I am a software developer and international dance fitness instructor

No responses yet