<commit_before>import React from 'react';
import CommentForm from 'components/CommentForm';
import {connect} from 'react-redux';
import {initialize} from 'redux-form';

export class newComment extends React.Component {

  constructor () {
    super();
  }

  handleSubmit(data) {
    console.log('Submission received!', data);
    this.props.dispatch(initialize('contact', {})); // clear form
  }

  render () {
    return (
      <div className='container text-center'>
        <h1>Write a new comment</h1>
        <CommentForm onSubmit={this.handleSubmit.bind(this)}/>
      </div>
    );
  }
}

export default connect()(newComment);  // adds dispatch prop
<commit_msg>add state connect<commit_after>import React from 'react';
import CommentForm from 'components/CommentForm';
import { initialize } from 'redux-form';
import { connect } from 'react-redux';
import { addComment } from 'actions';
import { FORM_COMMENT_ID } from 'constants';

@connect(state => ({
  dispatch: state
}))
export class newComment extends React.Component {

  static propTypes = {
    dispatch: React.PropTypes.func,
    history: React.PropTypes.object
  }

  constructor () {
    super();
  }

  handleSubmit(data) {
    // save form
    this.props.dispatch(addComment(data));
    // clear form inputs
    this.props.dispatch(initialize( FORM_COMMENT_ID, {}));
    // show comments
    this.props.history.pushState(null, '/');
  }

  render () {
    return (
      <div className='container text-center'>
        <h1>Write a new comment</h1>
        <CommentForm onSubmit={this.handleSubmit.bind(this)}/>
      </div>
    );
  }
}

export default newComment;
// export default connect()(newComment);

{'fraction_non_alphanumeric': 0.1392857142857143, 'fraction_numerical': 0.002380952380952381, 'mean_word_length': 3.4588859416445623, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '492069', 'n_tokens_mistral': 504, 'n_tokens_neox': 499, 'n_words': 120}