jeudi 1 novembre 2018

Return value in if condition using ReactJS

I have the following block of code:

      <div className="max">
        {Math.max.apply(
          Math,
          items.feeds.map(function(o) {
            const temp = 34;

            if(o.field1 <= temp) {
              return <b>{o.field1}</b>; //return NaN
             }
            else {
               return o.field1;
            }

          })
        )}
      </div>

However, the if statement returns NaN. If I just return o.field1, it works. Like this:

items.feeds.map (function (o) {return o.field1}

Is there an issue in my if statement? I want if the value of o.field1 satisfies the condition when printing to screen it is bold.

Aucun commentaire:

Enregistrer un commentaire