React - Difference between with or without div for constant

0 votes
33 views
added Feb 1 in React by lcjr First Warrant Officer (11,850 points)

With <div>

const latestKeyedText =
cookies && cookies.searchHistory && cookies.searchHistory.length > 0 ? (
  <div key={cookies.searchHistory.length - 1}>
    {`${cookies.searchHistory[cookies.searchHistory.length - 1]}`}
  </div>
) : null;

 

Without <div>

const latestKeyedText =
cookies && cookies.searchHistory && cookies.searchHistory.length > 0
  ? `${cookies.searchHistory[cookies.searchHistory.length - 1]}`
  : null;

 

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