Looking for some ideas as to how to improve the below react component.
var JSON_URL = "https://api.example.io/comments.json";
class CommentList extends React.Component {
constructor() {
super();
this.state = { comments: [] }
}
componentDidMount() {
$.ajax({
url: JSON_URL,
dataType: 'json',
success: function(data) {
this.setState({comments: data.comments});
}.bind(this)
});
};
render() {
return <ul> {
this.state.comments.map((comment) => {
return <li>{comment.body}—{comment.author}</li>;
})}
</ul>;
}
}
React.render(<CommentList />, document.getElementById('root'));