<commit_before>var elementResizeEvent = require('element-resize-event');

module.exports = {
  getInitialState: function() {
    if (this.props.initialComponentWidth !== undefined && this.props.initialComponentWidth !== null) {
      return {
        componentWidth: this.props.initialComponentWidth
      };
    }
  },
  // Add our resize sensor.
  componentDidMount: function() {
    this.setState({componentWidth: this.getDOMNode().offsetWidth});
    elementResizeEvent(this.getDOMNode(), this.onResize);
  },
  // When the DOM updates, check that our resize sensor is still there.
  componentDidUpdate: function() {
    if (0 === this.getDOMNode().getElementsByClassName('resize-sensor').length) {
      elementResizeEvent(this.getDOMNode(), this.onResize);
    }
  },
  onResize: function () {
    this.setState({componentWidth: this.getDOMNode().offsetWidth});
  }
};<commit_msg>getInitialState has to always return something<commit_after>var elementResizeEvent = require('element-resize-event');

module.exports = {
  getInitialState: function() {
    if (this.props.initialComponentWidth !== undefined && this.props.initialComponentWidth !== null) {
      return {
        componentWidth: this.props.initialComponentWidth
      };
    } else {
      return {};
    }
  },
  // Add our resize sensor.
  componentDidMount: function() {
    this.setState({
      componentWidth: this.getDOMNode().offsetWidth
    });
    elementResizeEvent(this.getDOMNode(), this.onResize);
  },
  // When the DOM updates, check that our resize sensor is still there.
  componentDidUpdate: function() {
    if (0 === this.getDOMNode().getElementsByClassName('resize-sensor').length) {
      elementResizeEvent(this.getDOMNode(), this.onResize);
    }
  },
  onResize: function() {
    this.setState({
      componentWidth: this.getDOMNode().offsetWidth
    });
  }
};
{'fraction_non_alphanumeric': 0.13523706896551724, 'fraction_numerical': 0.0010775862068965517, 'mean_word_length': 3.713197969543147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2152789', 'n_tokens_mistral': 521, 'n_tokens_neox': 532, 'n_words': 103}