if else inside return in reactjs code example
Example 1: adding a if stement in jsx
render() {
return (
{this.state.value == 'news'? data : null }
)
}
Example 2: react if statement
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
The user is {isLoggedIn ? 'currently' : 'not'} logged in.
);
}