<commit_before>import React, {PropTypes, Component} from 'react';
import {View} from 'react-native';

export default class Form extends Component {
  _listeners = [];

  static PropTypes = {
    onSuccess: PropTypes.func,
    onFail: PropTypes.func,
    submitButton: PropTypes.element.isRequired
  }

  static childContextTypes = {
    addFormListener: PropTypes.func,
    removeFormListener: PropTypes.func
  }

  getChildContext() {
    return {
      addFormListener: this.addFormListener.bind(this),
      removeFormListener: this.removeFormListener.bind(this)
    }
  }

  addFormListener(ln) {
    this._listeners.push(ln);
  }

  removeFormListener(ln) {
    this._listeners = this._listeners.filter(l => l  !== ln);
  }

  onSubmit() {
    const defaultFn = () => {};
    const {onFail = defaultFn, onSuccess = defaultFn} = this.props;

    const stop = this._listeners.reduce((stop, _listener) => {
      return _listener() || stop;
    }, false);
    if (stop) {
      return onFail();
    };
    onSuccess();
  }

  render() {
    const {submitButton, children, style} = this.props;

    return (
        <View style={style}>
          {children}
          {submitButton(this.onSubmit.bind(this))}
        </View>
    )
  }
}<commit_msg>Add prop to disable submit<commit_after>import React, {PropTypes, Component} from 'react';
import {View} from 'react-native';

export default class Form extends Component {
  _listeners = [];

  static PropTypes = {
    onSuccess: PropTypes.func,
    onFail: PropTypes.func,
    submitButton: PropTypes.element.isRequired
  }

  static childContextTypes = {
    addFormListener: PropTypes.func,
    removeFormListener: PropTypes.func
  }

  getChildContext() {
    return {
      addFormListener: this.addFormListener.bind(this),
      removeFormListener: this.removeFormListener.bind(this)
    }
  }

  addFormListener(ln) {
    this._listeners.push(ln);
  }

  removeFormListener(ln) {
    this._listeners = this._listeners.filter(l => l  !== ln);
  }

  onSubmit() {
    const defaultFn = () => {};
    const {onFail = defaultFn, onSuccess = defaultFn} = this.props;

    const stop = this._listeners.reduce((stop, _listener) => {
      return _listener() || stop;
    }, false);
    if (stop) {
      return onFail();
    };
    onSuccess();
  }

  render() {
    const {submitButton, children, style, disableSubmit} = this.props;

    return (
        <View style={style}>
          {children}
          {submitButton(this.onSubmit.bind(this), disableSubmit)}
        </View>
    )
  }
}
{'fraction_non_alphanumeric': 0.1306572215663125, 'fraction_numerical': 0.0, 'mean_word_length': 2.9410852713178293, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '2517704', 'n_tokens_mistral': 792, 'n_tokens_neox': 784, 'n_words': 162}