Revised by
Joo
a9d2aa9
| var CommentBox = React.createClass({
getInitialState: function() {
return {
count: sample.count,
data: sample.list
};
},
handleCommentSubmit: function(comment) {
this.setState({
count: this.state.count + 1,
data: this.state.data.concat(comment)
});
},
handleMoreList: function() {
this.setState({
data: sample.olderList.concat(this.state.data)
});
},
render: function() {
return (
<div className="commentBox">
<h3>Comments {this.state.count}</h3>
<CommentList data={this.state.data} count={this.state.count} onClickMoreList={this.handleMoreList} />
<CommentForm onCommentSubmit={this.handleCommentSubmit} />
</div>
);
}
});
|