I want to return null if condition meets and if not render a component using ternary operator in react and typescript.
What I am trying to do?
I have the code like below,
{condition1 && condition2 && (
<firstdiv>
<seconddiv>
<Icon />
</seconddiv>
</firstdiv>
)}
So as seen above if condition1 and condition2 is true then it renders firstdiv.
Now I have to return null if condition3 is true.
So in easy if and else something like this,
if (condition1 && condition2) {
if (condition3) {
return null;
} else {
return firstdiv;
}
}
So to do that I tried something like below with ternary operator in jsx
{conditon1 && condition2 && (
{condition3 ? return null : (
<firstdiv>
<seconddiv>
<Icon/>
</seconddiv>
</firstdiv>)
})}
But this doesn't seem to be correct syntax. Could someone help me fix this? Thanks.