React - change className through conditional rendering

0 votes
84 views
added Apr 12, 2021 in React by lcjr First Warrant Officer (9,190 points)
<div
  className={
    agentURL ? 'text-secondary url-exist' : 'text-secondary'
  }
>
  <span className="agency-name">{agencyName}</span>
  <span className="agent-id">{agentID}</span>
  {agentURL && (
    <span>
      <a className="agent-url" target="_blank" href={`http://${agentURL}`}>{agentURL}</a>
    </span>
  )}
</div>

 

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