Current section: TypeScript 59 exercises
Problem

Default Props

Loading exercise

Transcript

00:00 Another thing that we do commonly with components is have default values and so we're going to have some default values for our calculator props. We want to set those default values for our calculator props and we're going to use those default values. We're going to kind of take this a

00:16 little bit beyond what you might do for this particular component, but let's say that the default for left is zero, the default for right is also zero, and maybe even the default for the operator could be plus or yeah we'll just go with that. And with that then we can actually remove

00:36 the things that are optional. So right now if I try to do that we're going to get an error right here. So your job is to make it so that those things can be optional and that they have the proper default value. You're going to be using a combination of TypeScript syntax for making the

00:53 props optional and the optional properties syntax of an object. So have a good time with this. We'll see you when you're done.