Current section: Prop Collections and Getters 30 exercises
Problem

Prop Collections

Loading exercise

Transcript

00:00 If we take a look at our app, we'll notice we have this useToggle function, this hook, that's what we're going to be using here. It's giving us the on state. It also gives us a toggle function. But what we want is a toggler props. So we've got two togglers here.

00:19 These should be props that I apply to a function or an element that is a toggler. So it should give me an onClick, and it should give me pretty much actually just the onClick.

00:35 Maybe ARIA attributes and stuff like that too. So here we have our switch, we have our button, and the cool thing about the toggler props is that it is an implementation detail. So I don't have to know what props it provides. Maybe it's onPress instead of onClick and stuff like that. So I don't have to worry about that.

00:54 All I know is I take these toggle props, I spread it across the thing that I want to take the role of a toggler, and now I have that control. Now, of course, it's not working because your job is to actually implement the toggler props, and I think you're going to do a great job. So let's get started.