react visible if code example Example 1: react native conditional rendering class Component extends React.Component { const a = true render() { return ( {a == true ? () : null } ) } } This is staying: if a == true, render a button component. Otherwise render null, in other words nothing. Example 2: ternary react render() { const isLoggedIn = this.state.isLoggedIn; return ( The user is {isLoggedIn ? 'currently' : 'not'} logged in. ); } Example 3: react native conditional rendering function Mailbox(props) { const unreadMessages = props.unreadMessages; return ( Hello! {unreadMessages.length > 0 && You have {unreadMessages.length} unread messages. } ); }