mercredi 28 octobre 2015

IF block inside render function ReactJS

Am newbie to ReactJS. I want to use a IF block inside the render function. While search for this I got result like "You should use ternary operator instead of IF statement". But if I want to use something like,

$.each(array, function(i, x) {
  var flag = 0
  if({x.a1} || !{x.a2}) {
    flag = 1;
    <p>true flag enabled</p>
  }
  <p>...</p>
 });

How to convert this statement into JSX syntax or how to use it in React render fucntion.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire