Hello @kartik,
Let's define a simple helping If component:
var If = React.createClass({
render: function() {
if (this.props.test) {
return this.props.children;
}
else {
return false;
}
}
});
And use it this way:
render: function () {
return (
<div id="page">
<If test={this.state.banner}>
<div id="banner">{this.state.banner}</div>
</If>
<div id="other-content">
blah blah blah...
</div>
</div>
);
}
Hope it helps!!
To know more about React, We highly recommend to join React Training online today.
Thank You!!