课程: React.js: Building an Interface
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
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…