Reputation: 15
for a control panel i want to limit the display of a content, each category is defined by a number and it looks like that
Works perfectly
{nestId === 1 &&
<<content here>>
}
With multiple numbers Not working (what is wrong?)
{nestId === 1 || nestId === 5 &&
<<content here>>
}
I want to include more numbers, i tried this way, but it doesnt display correctly, from the number 1 it disappear but instead it appears on the number 5. What am i doing wrong? Can someone explain it to me?
Upvotes: 1
Views: 20
Reputation: 10662
Use parentheses to better inform React what should be evaluated first:
{
(nestId === 1 || nestId === 5) && <<content here>>
}
or if you have a lot of numbers to check:
{
[1,5].includes(nestId) && << content here >>
}
Upvotes: 2