JSX da shartlarni qo'llash

Keling, show doimiyasining mazmuniga qarab ekranda bitta yoki boshqa matn chiqarilishini qilaylik:

jsxfunction App() {
  let text;
  const show = true;
  
  if (show) {
    text = 'text1';
  } else {
    text = 'text2';
  }
  
  return <div>
    {text}
  </div>;
}

O'zgaruvchida matn emas, balki teg saqlanishi mumkin:

jsxfunction App() {
  let text;
  const show = true;
  
  if (show) {
    text = <p>text1</p>;
  } else {
    text = <p>text2</p>;
  }
  
  return <div>
    {text}
  </div>;
}