<commit_before>import React from 'react';
import {
  StyleSheet,
  Text,
  TouchableHighlight,
  View,
} from 'react-native';

export function Button(props) {
  if (props.isDisabled) {
    return (
      <View style={[props.style, { backgroundColor: props.disabledColor }]}>
        <Text style={props.textStyle}>{props.text}</Text>
      </View>
    );
  }
  return (
    <TouchableHighlight
      style={props.style}
      underlayColor="#B5B5B5"
      onPress={() => {
        props.onPress();
      }}
    >
      <Text style={props.textStyle}>{props.text}</Text>
    </TouchableHighlight>
  );
}

Button.propTypes = {
  style: View.propTypes.style,
  textStyle: Text.propTypes.style,
  onPress: React.PropTypes.func,
  text: React.PropTypes.string,
  isDisabled: React.PropTypes.bool,
  disabledColor: React.PropTypes.string,
};

const styles = StyleSheet.create({
  button: {
    padding: 15,
    borderBottomWidth: StyleSheet.hairlineWidth,
    borderBottomColor: '#CDCDCD',
  },
  buttonText: {
    fontSize: 17,
    fontWeight: '500',
  },
});

Button.defaultProps = { // 'styles' needs to be declared before use!
  style: styles.button,
  textStyle: styles.buttonText,
};
<commit_msg>Fixes spamming create new invoice, structure for changing appearance when running a function<commit_after>import React from 'react';
import {
  StyleSheet,
  Text,
  TouchableHighlight,
  View,
} from 'react-native';

export class Button extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isLoading: false,
    };
  }

  async onPress() {
    // By definition, the second argument should be called after rerender (doesn't appear to)
    await this.setState({ isLoading: true }, this.props.onPress);
    this.setState({ isLoading: false });
  }

  render() {
    const props = this.props;
    if (props.isDisabled) {
      return (
        <View style={[props.style, { backgroundColor: props.disabledColor }]}>
          <Text style={props.textStyle}>{props.text}</Text>
        </View>
      );
    }
    if (this.state.isLoading) {
      return (
        <View style={[props.style, { backgroundColor: props.disabledColor }]}>
          <Text style={props.textStyle}>Working</Text>
        </View>
      );
    }

    return (
      <TouchableHighlight
        style={props.style}
        underlayColor="#B5B5B5"
        onPress={() => { this.onPress(); }}
      >
        <Text style={props.textStyle}>{props.text}</Text>
      </TouchableHighlight>
    );
  }
}

Button.propTypes = {
  style: View.propTypes.style,
  textStyle: Text.propTypes.style,
  onPress: React.PropTypes.func,
  text: React.PropTypes.string,
  isDisabled: React.PropTypes.bool,
  disabledColor: React.PropTypes.string,
};

const styles = StyleSheet.create({
  button: {
    padding: 15,
    borderBottomWidth: StyleSheet.hairlineWidth,
    borderBottomColor: '#CDCDCD',
  },
  buttonText: {
    fontSize: 17,
    fontWeight: '500',
  },
});

Button.defaultProps = { // 'styles' needs to be declared before use!
  style: styles.button,
  textStyle: styles.buttonText,
};

{'fraction_non_alphanumeric': 0.13896103896103895, 'fraction_numerical': 0.006493506493506494, 'mean_word_length': 3.0486202365308803, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '1838516', 'n_tokens_mistral': 1003, 'n_tokens_neox': 978, 'n_words': 202}