using jsx element as if condition code example
Example 1: how to use if else inside jsx in react
renderElement(){
if(this.state.value == 'news')
return data ;
return null;
}
render() {
return (
{ this.renderElement() }
)
}
Example 2: make a if in jsx
var loginButton;
if (loggedIn) {
loginButton = ;
} else {
loginButton = ;
}
return (
);