In React I can conditionally render any div like:
{hasContent &&
<span>{value}</span>
}
I'm trying to put in two conditions like this:
{hasContent || hasDesc &&
<span>{value}</span>
}
but it doesn't work.
I want to render the span if there is hasContent or hasDesc.
How can I do that?
It's just operator precedence: && takes priority over ||. Just use parentheses to get it processed the way you want:
{(hasContent || hasDesc) &&
<span>{value}</span>
}