美文网首页
Handling Event

Handling Event

作者: bestCindy | 来源:发表于2020-08-13 16:19 被阅读0次
  • 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