why this coditional is not working:
{
selectedConfig === "house" ||
selectedConfig === "Zone" ||
selectedConfig === "Departament" &&
<div>
<div className="flex flex-col w-1/2">
<InputForn
text="Nom"
name="nom"
inputType="text"
value=""
/>
</div>
<div className="flex flex-col w-1/2">
<InputForn
text="URL "
name="url"
inputType="text"
value=""
/>
</div>
</div>
}
It’s react js, I’m creating one conditional to show/hide some component, so currently It’s showing when I select Departament
but not work when conditional are house or zone
I think that operator ||
not work, why?? or what can I do to work it ???
2
Answers
You need to group conditions with parentheses :
Add parens.
The problem is that
&&
has higher precedence than||
.This means that
is equivalent to
But you want
As an aside, you say you want to check for
zone
, but you check forZone
. You are using inconsistent capitalization, and you misspelled "department". This is error prone.