From the course: React for Web Designers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Wire up the filters form

Wire up the filters form - React.js Tutorial

From the course: React for Web Designers

Wire up the filters form

up the filter form fields as controlled elements, that update some new state variables tracking their contents. So as of now, I can type in these and nothing happens. We're going to change these so they are controlled. So first, we know we're going to need to track some new state. We're going to need to track the currently typed in name, the currently selected title and whether We'll add a key called current name which will start out empty. Likewise the current title, also empty. And we'll use isIntern to track whether that checkbox is checked, and that will start as false. So these are the pieces of state we have at the Directory level, and we'll pass these into the filters as props. We're keeping the state here at the Directory level because these are all going to influence each other. Seems like the right place for now. So we'll pass these all in currentName equals this.state.currentName, currentTitle is this.state.currentTitle. We'll also pass in isIntern this.state.isIntern…

Contents