Skip to content

Instantly share code, notes, and snippets.

@domyen
Last active March 29, 2017 20:35
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 domyen/599922877e310d5b9ad13ac8291acb9c to your computer and use it in GitHub Desktop.
Save domyen/599922877e310d5b9ad13ac8291acb9c to your computer and use it in GitHub Desktop.
Data container component example (via @chantastic)
// CommentListContainer.jsx (DATA)
class CommentListContainer extends React.Component {
constructor() {
super();
this.state = { comments: [] }
}
componentDidMount() {
$.ajax({
url: "/my-comments.json",
dataType: 'json',
success: function(comments) {
this.setState({comments: comments});
}.bind(this)
});
}
render() {
return <CommentList comments={this.state.comments} />;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment