140k views
5 votes
How do you destructure the properties that are sent to the Dish component?

function Dish(props) {
return (

{ } {props.cookingTime}

);
}

1 Answer

4 votes

Final answer:

To destructure the properties that are sent to the Dish component, you can use the ES6 destructuring syntax.

Step-by-step explanation:

In order to destructure the properties that are sent to the Dish component, you can use the ES6 destructuring syntax. In this example, the properties are passed through the props object. To destructure the cookingTime property, you can write:



function Dish({ cookingTime }) {
return (
<div>
The cooking time is {cookingTime}
</div>
);
}



This way, you can directly access the cookingTime property without referencing it through the props object every time.

User LarrikJ
by
7.9k points

No related questions found