best way to write if statement in react code example
Example 1: if else render react
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
{isLoggedIn ? (
) : (
)}
);
}
Example 2: adding a if stement in jsx
render() {
return (
{this.state.value == 'news'? data : null }
)
}