Snippets

Joo Comment.jsx

You are viewing an old version of this snippet. View the current version.
Revised by Joo 82d2807
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>
		);
	}
});
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.