i'm trying implement "show more" feature comment section in reactjs when click show more doesn't load whole array removes show more link. here code:
var commentbox = react.createclass({ getinitialstate: function() { return {limit:3 ,showmore:false}; }, showmore:function() { this.setstate({showmore: true, limit: this.props.comments.length}); }, render: function() { var cls=[]; var length=this.props.comments.length; if(length >= this.state.limit){ cls=[]; (var i=0;i<this.state.limit;i++ ) cls.push(this.props.comments[i]); } return ( <div classname="commentbox"> <commentlist data={cls} /> {length> 3 &&!this.state.showmore? <div><a onclick={this.showmore} >show more</a></div>: null} </div> ); } });
making change state.comments doesn't affect view @ all.
this works: http://jsbin.com/ceqisepewu/edit?js,console,output
compare solution , find reason did not work.