if else react js render code example
Example 1: adding a if stement in jsx
render() {
return (
{this.state.value == 'news'? data : null }
)
}
Example 2: react native conditional rendering
function Mailbox(props) {
const unreadMessages = props.unreadMessages;
return (
Hello!
{unreadMessages.length > 0 &&
You have {unreadMessages.length} unread messages.
}
);
}