I have a component that accepts props like this:
<Description
priceValue={
product.price && isOutlet
? product.price_outlet === '0'
? ''
: `${product.price_outlet}`
: `${product.price}`
}
/>
I would like to not put all this condition inside the priceValue prop.
My solution is:
const PriceBox = () => {
return product.price && isOutlet
? product.price_outlet === '0'
? ''
: `${product.price_outlet} ${product.currencySymbol}`
: `${product.price} ${product.currencySymbol}`;
};
<Description priceValue={<PriceBox/>}/>
Can anyone tip me if there is a cleaner way to achieve it?
Thanks in advance