React - menu active with conditional rendering example

0 votes
184 views
added Apr 14, 2021 in React by lcjr First Warrant Officer (11,830 points)
<button
  type="button"
  className={
    type === '' ? 'btn btn-primary' : 'btn btn-secondary'
  }
  onClick={this.showAll}
>
  {/* All ({data.found}) */}
  All
</button>
<button
  type="button"
  className={
    type === 'sale' ? 'btn btn-primary' : 'btn btn-secondary'
  }
  onClick={this.showBuy}
>
  Buy
  {/* ({data.listsum.sale}) */}
</button>
<button
  type="button"
  className={
    type === 'rent' ? 'btn btn-primary' : 'btn btn-secondary'
  }
  onClick={this.showRent}
>
  Rent
  {/* ({data.listsum.rent}) */}
</button>

 

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