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!
It's called conditional rendering
<div>
{ this.state.sWA1>15 &&
<div>
//show picture
</div>}
{ this.state.sWA1>5 && this.state.sWA1<15
<div>
//show picture
</div>}
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With