From the course: React.js: Building an Interface

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Searching with a filtered array

Searching with a filtered array - React.js Tutorial

From the course: React.js: Building an Interface

Start my 1-month free trial

Searching with a filtered array

- [Instructor] Let's take a look at how we might code some search functionality into our component. So I'm going to start with the search component and what I need to do here is trigger an event, when somebody types something into the search box, which is right here. What I'll do is create an onChange event. And this is going to have an event variable that will get created for us based on what happens when somebody types in something, and that's going to trigger this arrow function. And then we're going to trigger an event which will appear on the parent component called onQueryChange. That event is going to get past the target.value here, which means that it will get whatever it is in this input field. All right, so that means that we're going to need, eventually, once that gets modified, we'll need to change or make sure that the value gets tracked also right here. So there's going to be some two way communication…

Contents