LoginSignup
8
7

More than 5 years have passed since last update.

【メモアプリ】renderでのforの使用例

Last updated at Posted at 2015-09-05

renderでのforの使用例

renderの際にloop処理にて複数の行を表示させたい場合、配列のmapなど使用例は、よく見受けられるが。
for文での使用例は、見受けられないため、以下に記載する。

getDefaultProps: function(){
      return{
           allowLines: 4
      }
 },
 renderLine: function(number){
      var lines = [];
      for(var i=0; i < number; i++){
           lines.push(<InputLine num={i+1}></InputLine>)
      }
      return lines;
 },
 render: function(){
      return (
           <div>
                {this.renderLine(this.props.allowLines)}
           </div>
      );
}
8
7
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
8
7