react if statement then render code example
Example 1: if else react render in jsc
const functionalComponent=()=> {
return (
{
props.isFeatured ? (
lol
) : ("")
}
);
}
Example 2: how to use if else inside jsx in react
renderElement(){
if(this.state.value == 'news')
return data ;
return null;
}
render() {
return (
{ this.renderElement() }
)
}
Example 3: react if statement
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
The user is {isLoggedIn ? 'currently' : 'not'} logged in.
);
}