react if else in component code example
Example 1: if else react render in jsc
const functionalComponent=()=> {
return (
{
props.isFeatured ? (
lol
) : ("")
}
);
}
Example 2: if else render react
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
{isLoggedIn ? (
) : (
)}
);
}
Example 3: react if statement
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
The user is {isLoggedIn ? 'currently' : 'not'} logged in.
);
}