Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

React - wrap react element with react frament <>

0 votes
17 views
added Apr 20 in React by lcjr Second Warrant Officer (5,360 points)

Need to wrap HTML & JS in div to write code, but you don't need one. Instead, use react frament <>your code</>.

const agentNumber = get(data, 'agent_contact_s_lower', '');
  const resultCallForPrice = get(data, 'call_for_price', '');
  let callForPriceCheck;
  if (resultCallForPrice === 'yes') {
    callForPriceCheck = (
      <>
        <a href={`tel:${agentNumber}`}>Call for price</a>
      </>
    );
  } else {
    callForPriceCheck = <>{accounting.formatMoney(listingPrice, 'RM ', 0)}</>;
  }
  
  return (
    <>
      <div className="mobile-view">
        <p className="card-price">{callForPriceCheck}</p>{' '}
      
      <div className="desktop-view">
        <p className="card-price">{callForPriceCheck}</p>{' '}
      
     </>

 

Please log in or register to response this reference.

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