function Mailbox(props) {
const unreadMessages = props.unreadMessages;
return (
<div>
<h1>Hello!</h1>
{unreadMessages.length > 0 &&
<h2>
You have {unreadMessages.length} unread messages.
</h2>
}
</div>
);
}
const messages = ['React', 'Re: React', 'Re:Re: React'];
ReactDOM.render(
<Mailbox unreadMessages={messages} />,
document.getElementById('root')
);
Operators
The Mailbox component will keep track of the number of unread messages in its props.unreadMessages property. When rendered, the component will display a header that says "Hello! You have {unreadMessages.length} unread messages." The unreadMessages property will contain an array of strings, each of which corresponds to a different message.
0 Comments
Add Comment
Log in to add a comment