Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
How to set || operator with jsx ? React

I need to set up two if with React this is my code:

      <div>
        {item?.status === "One" ||
          (item?.status === "Two" && (
            <Button 
              btn="primary"  title="One text"
            />
          ))}

           <Button btn="primary" title="Two text" />
       </div>

I need to render first button if item.status === "One" or ( || ) "Two" but this is no work? Where is problem ?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Why don't you try

<div>
  {(item?.status === "One" || item?.status === "Two") && (
    <Button btn="primary" title="One text" />
  )}
  <Button btn="primary" title="Two text" />
</div>;

You had encapsulated (item?.status === "Two" && <Button btn="primary" title="One text" />) which may caused a problem with your logic.

about 4 years ago · Juan Pablo Isaza Report

0

Fix your parenthesis for your rendering condition. You should wrap your boolean expression and code statement like {(boolean expressions) && (code statements)}:

 <div>
    {
    (item?.status === "One" || item?.status === "Two") && (
        <Button 
          btn="primary"  title="One text"
        />
      )
    }

       <Button btn="primary" title="Two text" />
   </div>

The line separation for the parenthesis and braces is just a stylistic preference of mine.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!