70
rated 0 times
[
76]
[
6]
/ answers: 1 / hits: 103016
/ 8 Years ago, sun, august 7, 2016, 12:00:00
I want to write the equivalent in react:
if (this.props.conditionA) {
<span>Condition A</span>
} else if (this.props.conditionB) {
<span>Condition B</span>
} else {
<span>Neither</span>
}
So maybe
render() {
return (<div>
{(function(){
if (this.props.conditionA) {
return <span>Condition A</span>
} else if (this.props.conditionB) {
return <span>Condition B</span>
} else {
return <span>Neither</span>
}
}).call(this)}
</div>)
}
But that seems overly complex. Is there a better way?
More From » reactjs