I have the following sequence of code in React:
{financialPerformance && (
financialPerformance.isConfirmed ? (
<L.Text txtGray>Confirmed</L.Text>
) : (
<L.Text txtGray>Not Confirmed</L.Text>
)
)}
I have to check financialPerformance itself as well for null or empty or undefined and display "Non Confirmed" message. I mean on first appearance of financialPerformance object.
{financialPerformance && (
How can I do that inside or out of block above?
Due to null and undefined will be evaluated to false in boolean context - you can just combine your checks at one place:
{
financialPerformance && financialPerformance.isConfirmed ? (
<L.Text txtGray>Confirmed</L.Text>
) : (
<L.Text txtGray>Not Confirmed</L.Text>
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With