Last active
August 20, 2016 04:40
-
-
Save waltzaround/36b27cb78337bc353abbcd88a8360484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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