React - hide when data is null through conditional rendering &&

0 votes
301 views
added Apr 12, 2021 in React by lcjr First Warrant Officer (11,530 points)
{agencyURL && (
  <span>
    <a className="agency-url" target="_blank" href={`http://${agencyURL}`}>{agencyURL}</a>
  </span>
)} 

 

2 Responses

0 votes
responded Apr 12, 2021 by lcjr First Warrant Officer (11,530 points)
{agencyLogo && (
  <div
    css={css`
      display: inline-block;
      width: auto;
      margin-top: 8px;
      border-radius: 5px;
      overflow: hidden;
      padding: 0;
    `}
  >
    <img
      css={css`
        margin: 0 auto;
        height: 40px;
      `}
      src={agencyLogo}
      alt={agencyName}
    />
  </div>
)}

 

0 votes
responded Apr 16, 2021 by lcjr First Warrant Officer (11,530 points)
{!isMobile && (
  <span>
   This content will appear for desktop and tab, not for mobile
  </span>
)} 

 

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