Reputation: 97
I'm trying to render a mui icon if a condition is met but it is crashing my app. I believe it's probably because I'm calling PriceCheckIcon in {}. any help?
<span
style={
Price > cinemaWorldPrice ? { color: "green" } : { color: "red" }
}
>
{error && Price > cinemaWorldPrice ? (
<div>{PriceCheckIcon}</div>
) : (
Number(cinemaWorldPrice).toFixed(2)
)}
</span>
Error message:
react-dom.development.js:14757 Uncaught Error: Objects are not valid as a React child (found: object with keys {$$typeof, type, compare}). If you meant to render a collection of children, use an array instead
Upvotes: 2
Views: 722
Reputation: 81
PriceCheckIcon needs to be used in JSX form.
Change:
<div>{PriceCheckIcon}</div>
to
<PriceCheckIcon />
Upvotes: 3