vendredi 3 mars 2017

How to do multiple if else statements in React?

So I am trying to create an if else statement similar too the following in React...

(where aNumber is any number)

if(aNumber < 5){
    show a picture
}else if (aNumber < 10){
    show a different picture
}else if (aNumber < 15){
    show another different picture
}else{
    show a some other 4th picture
}

In my table this.state.sWA1 returns a wind speed, so If its above a certain value I want to show a different picture depending on how high the wind speed is

<td>{this.state.sWA1 > '15' ? <img src={require('../arrowUp.png')} /> : <img src={require('../arrowDown.png')} /> }</td>

This currently works but I can only seem to find help with one if else statement rather than several if else statements, can anyone help or suggest an alternative approach?

Thank you!

Aucun commentaire:

Enregistrer un commentaire