From the course: React.js: Building an Interface

Unlock the full course today

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

Passing state and hiding components

Passing state and hiding components - React.js Tutorial

From the course: React.js: Building an Interface

Start my 1-month free trial

Passing state and hiding components

- [Instructor] So let's work on the toggle that's going to turn on and off this extra dropdown whenever we specify how things should be sorted. So, it sounds like it should be pretty similar to Add Appointment and it is, but there are some interesting differences right here. So, it's going to seem pretty similar at least. Let's go ahead and import state. So, useState from react, and that means that we can useState in any of these two different components. So, we have two components here and what we want to do is actually pass information about the state from this main component into this sub-component. So, to do that, we're going to create some state variables here. So, we'll say toggleSort and setToggleSort. So, that's how we're going to update things. And we'll ask it to useState, and we want this one, like the previous one to be set to false by default, so it doesn't show up. All right. So, in a similar fashion…

Contents