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

114
Views
Displaying JSX/HTML based on props

What is this kind of expression called and how or when should it be used?

{props.type === "big" && <h2>{props.title}</h2>}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The {} part is a JSX expression that allows you to embed JavaScript code in JSX markup.

The && is a logical AND operator, but in JavaScript, instead of resulting in either true or false, && does this:

  1. Evaluates its left-hand operand
  2. If the value from Step 1 is falsy, the && operation takes that result as its result and stops here
  3. If the value from Step 1 is truthy (the opposite of falsy), the && operation evaluates the right-hand operand and takes that value as its result

So props.type === "big" && <h2>{props.title}</h2> means:

  • If props.type is "big", put <h2>{props.title}</h2> here.
  • If not, put nothing here (because React doesn't render false, null, or undefined)

how or when should it be used

It's typically used when you need to render something conditionally. The condition is the first part (props.type === "big"). The thing being rendered, or not being rendered, is the second part (<h2>{props.title}</h2>).

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!