Reputation: 144
Given a component Product with a props interface ProductProps defined:
interface ProductProps {
name: string,
price: {
amount: number,
currency: string
}
}
how do I assign the values for price
in the component tag i.e. I want something to the effect of:
<Product name="Nice Shoes" price.amount={100} price.currency="$" />
Upvotes: 1
Views: 3069
Reputation: 657
Because price is an object too you could pass like so:
<Product name="Nice Shoes" price={{amount :100, currency:"$"}} />
The first set of parenthesis are for the jsx syntax and the second is for the object itself
Upvotes: 4