React - conditional rendering in backtick

0 votes
292 views
added Apr 27, 2021 in React by lcjr First Warrant Officer (11,830 points)
let carurlObj = { pathname: '/car-detail', query };
let carUrl = `/car/${carItemData.url_s}`;

if (isNewCar) {
  carurlObj = { pathname: '/new-car-detail', query };
  carUrl = `/new-launches/${carItemData.url_s}`;
}
if (isImportedCar) {
  carurlObj = `https://example.com/imported-car-detail/${carItemData.url_s}`;
  carUrl = `https://example.com/imported-car-detail/${carItemData.url_s}`;
}

 

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