JSX-da şertleri ulanmak

Geliň, show konstantasynyň mazmunyndan aslynda ekrana bir ýa-da beýleki tekstiň çykýan bolsun:

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

Üýtgeýjide tekst däl-de, teg saklanyp bolýandygyny ýa-da etmek bolýar:

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