LoginSignup
0
0

More than 3 years have passed since last update.

React if文構築の方法

Posted at

即時関数を用いる場合

 { (()=>{
          if(this.state.persons[0].name !=="genki"){
            return <p>Wrong</p>;
          }else{
            return <p>none</p>
          }
        })()
      }

三項演算子を利用する方法


     { 
          this.state.showPersons === true ?
            <div>
              <Person
                name={this.state.persons[0].name} 
                age={this.state.persons[0].age}  />
              <Person
                name={this.state.persons[1].name}
                age={this.state.persons[1].age}
                click={this.switchNameHandler.bind(this, "Max!!")}
                changed={this.nameChangedHandler} >
                My Hobbies: Racing
              </Person>
              <Person
                name={this.state.persons[2].name}
                age={this.state.persons[2].age}/> 
             </div> :null
       }

引用: https://www.yoheim.net/blog.php?q=20180409

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0