text: // Module imports to load in dependencies
  // Uses both default & named imports
  import React, {PropTypes, Component} from 'react';
  import CommentList from '../components/CommentList';
  import CommentForm from '../components/CommentForm';
  
  export default class App extends Component {
      static propTypes = {
          url: PropTypes.string.isRequired,
          pollInterval: PropTypes.number
      }
      static defaultProps = {
          pollInterval: 5000
      }
      state = {
          comments: []
      }
  
      componentDidMount() {
          this._loadCommentsFromServer();
  
          this._pollId = setInterval(this._loadCommentsFromServer.bind(this), this.props.pollInterval);
      }
      componentWillUnmount() {
          clearInterval(this._pollId);
      }
  
      _loadCommentsFromServer() {
          $.ajax({
              url: this.props.url,
              dataType: 'json',
              cache: false,
              success: (comments) => this.setState({comments}),
              error: (xhr, status, err) => console.error(this.props.url, status, err.toString())
          });
      }
      _handleCommentSubmit(comment) {
          // Optimistically set an id on the new comment. It will be replaced by an
          // id generated by the server. In a production application you would likely
          // not use Date.now() for this and would have a more robust system in place.
          let newComment = comment;
          let {comments} = this.state;
          let newComments;
  
          newComment.id = Date.now();
  
          newComments = comments.concat([comment]);
          this.setState({comments: newComments});
  
          $.ajax({
              url: this.props.url,
              dataType: 'json',
              type: 'POST',
              data: comment,
              success: (resComments) => this.setState({comments: resComments}),
              error: (xhr, status, err) => {
                  this.setState({comments});
                  console.error(this.props.url, status, err.toString());
              }
          });
      }
  
      render() {
          let {comments} = this.state;
  
          return (
              <div className="commentBox">
                  <h1>Comments</h1>
                  <CommentList comments={comments} />
                  <CommentForm onCommentSubmit={this._handleCommentSubmit.bind(this)} />
              </div>
          );
      }
  }
  