Skip to content

Instantly share code, notes, and snippets.

@waltzaround
Last active August 20, 2016 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waltzaround/36b27cb78337bc353abbcd88a8360484 to your computer and use it in GitHub Desktop.
Save waltzaround/36b27cb78337bc353abbcd88a8360484 to your computer and use it in GitHub Desktop.
//begin tutorial 13
var CommentBox = react.createClass({
getInitialState: function() {
return {data: []};
},
componentDidMount: function() {
$.ajax({
url: this.props.url,
datatype: 'json',
cache: false,
success: function(data) {
this.setState({data: data});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
render: function() {
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm />
</div>
);
}
});
//end tutorial 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment