Current section: Using JSX 59 exercises
Problem

Spread props

Loading exercise

Transcript

00:00 Sometimes you've got an object that has all the props that you want to apply to a particular element this happens quite often actually So here we have an example. We've got our children We've got our class name and then we stick that in a props element now or object and then maybe we pass it to a function or something like

00:16 That and so the way that you might do this. It's you'd say prop or class name equals props there we go props our class name and Children equals props on children you could do that Our AI assistant has actually kind of spoiled things for us a little bit

00:34 But the the idea is how do I take this object and apply all of those props to? that element without Having to name each one individually like maybe it's a little bit dynamic or something So if we were just writing regular create elements

00:51 If you I calls then we could just literally pass that props object along to create element and that would work just fine Or we could even make a new object and copy all of the props do it like a shallow copy of all the props Onto that new object like that would work fine

01:06 And so the the challenge for you in this exercise is how do you do that same thing on that element now? We're in a JSX syntax, so check out the references if you're not totally sure To how to do that, but it's pretty quick and pretty easy. We'll see you soon