zoukankan      html  css  js  c++  java
  • React 渲染组件

    function UserGreeting(props) {
      return <h1>欢迎回来!</h1>;
    }
    ---------------------------------------------------------------------------
    render() {
        const isLoggedIn = this.state.isLoggedIn;
     
        let button = null;
        if (isLoggedIn) {
          button = <LogoutButton onClick={this.handleLogoutClick} />;
        } else {
          button = <LoginButton onClick={this.handleLoginClick} />;
        }
     
        return (
          <div>
            <Greeting isLoggedIn={isLoggedIn} />
            {button}
          </div>
        );
    }
    ---------------------------------------------------------------------------
    function Mailbox(props) {
      const unreadMessages = props.unreadMessages;
      return (
        <div>
          <h1>Hello!</h1>
          {unreadMessages.length > 0 &&
            <h2>
              您有 {unreadMessages.length} 条未读信息。
            </h2>
          }
        </div>
      );
    }
     
    const messages = ['React', 'Re: React', 'Re:Re: React'];
    ReactDOM.render(
      <Mailbox unreadMessages={messages} />,
    );
    ---------------------------------------------------------------------------
    render() {
      const isLoggedIn = this.state.isLoggedIn;
      return (
        <div>
          {isLoggedIn ? (
            <LogoutButton onClick={this.handleLogoutClick} />
          ) : (
            <LoginButton onClick={this.handleLoginClick} />
          )}
        </div>
      );
    }
    
    

      

    const numbers = [1, 2, 3, 4, 5];
    const listItems = numbers.map((numbers) =>
      <li>{numbers}</li>
    );
     
    ReactDOM.render(
      <ul>{listItems}</ul>
    );
    

      

  • 相关阅读:
    Ubuntu 设置网卡固定IP
    gawk Notes(2)
    再读simpledb 之 存储的实现
    [zZ]HDFSRAID使用Erasure Code来实现HDFS的数据冗余
    初识gawk, gawk Notes(1)
    gawk notes(3)
    Shell Notes(2)
    凶残的突击面试
    Google 图片下载工具
    Shell Notes(3)
  • 原文地址:https://www.cnblogs.com/zhanglanzuopin/p/12925861.html
Copyright © 2011-2022 走看看