renderElement(){
if(this.state.value == 'news')
return <Text>data</Text>;
return null;
}
render() {
return (
<View style={styles.container}>
{ this.renderElement() }
</View>
)
}
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div>
The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in. </div>
);
}
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div>
{isLoggedIn
? <LogoutButton onClick={this.handleLogoutClick} />
: <LoginButton onClick={this.handleLoginClick} />
}
</div>
);
}
// Before your return / render block you could write something like this:
const ifThisOrThat = ifThis || ifThat;
// then you can use it in your return / render block like so:
{ ifThisOrThat &&
<p>I will render ifThis or ifThat is true!</p>
}
render() {
return <span>
{this.props.conditionA ? "Condition A"
: this.props.conditionB ? "Condition B"
: "Neither"}
</span>;
}
const functionalComponent=()=> {
return (
<div>{
props.isFeatured ? (
<div className="featured_ovelay_icon">lol</div>
) : ("")
}
</div>
);
}
var loginButton;
if (loggedIn) {
loginButton = <LogoutButton />;
} else {
loginButton = <LoginButton />;
}
return (
<nav>
<Home />
{loginButton}
</nav>
);
if (coinToss() === 'heads') {
img = <img src={pics.kitty} />
} else {
img = <img src={pics.doggy} />
}