React - JSX conditional rendering for 2 or 1 scenario

0 votes
14 views
added Apr 22 in React by lcjr First Warrant Officer (11,870 points)
// single scenario
{isListingExpired ? (
    <>Expired</>
) : (
    null
)}

// 2 scenarios
{isListingExpired ? 
  <>Expired</>
: (
  <>
  <i className="material-icons time-icon mr-2 my-auto">access_time</i>{' '}
  {dayjs(changed * 1000).fromNow()}
  </>
)} 

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...