Handling Event
- inline if with logical && operator
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")
)
- Returning
null
from a component's render
method does not affact the firing of the component's lifecycle methods
本文标题:Handling Event
本文链接:https://www.haomeiwen.com/subject/capbdktx.html
网友评论