if on jsx code example
Example 1: make a if in jsx
var loginButton;
if (loggedIn) {
loginButton = ;
} else {
loginButton = ;
}
return (
);
Example 2: react if statement
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
The user is {isLoggedIn ? 'currently' : 'not'} logged in.
);
}