Created
October 22, 2019 09:37
-
-
Save react-ram/9b96b4294b67ea26f17e3c55e846bdff to your computer and use it in GitHub Desktop.
basics - conditional rendering with inline logical && operator example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
const messages = ["react", "angular", "javascript"]; | |
function App() { | |
return <MailBox unreadMessages={messages} />; | |
} | |
function MailBox(props) { | |
const unreadMessages = props.unreadMessages; | |
return ( | |
<div> | |
{unreadMessages.length > 0 && ( | |
<h2>you have {unreadMessages.length} unread messages</h2> | |
)} | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment