<commit_before>
import React, {
  Component,
  PropTypes,
} from 'react';
import classNames from 'classnames';

class FieldMessage extends Component {

  constructor(props) {
    super(props);
    this.state = {
      isErrorDisplayed: true,
    };
    this.setBalloonWidthBound = this.setBalloonWidth.bind(this);
  }

  componentDidMount() {
    this.setBalloonWidth();
    window.addEventListener('resize', this.setBalloonWidthBound);
  }

  componentDidUpdate() {
    this.setBalloonWidth();
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.setBalloonWidthBound);
  }

  setBalloonWidth() {
    if (Object.keys(this.refs).length === 0) return;
    this.refs.balloon.style.width = '';
    const fieldEl = this.refs.componentRoot.children[0];
    this.refs.balloon.style.width = `${fieldEl.offsetWidth}px`;
  }

  render() {
    const classes = classNames('fieldMessage', this.props.className);

    const extendedProps = Object.assign({}, this.props, {
      className: classes,
    });

    let output;

    if (this.props.isDisplayed) {
      output = (
        <div ref="componentRoot" {...extendedProps}>
          {this.props.children}

          <div
            ref="balloon"
            className="fieldMessageBalloon"
          >
            {this.props.message}
          </div>
        </div>
      );
    } else {
      output = this.props.children;
    }

    return (
      <div>
        {output}
      </div><commit_msg>[BT-361] Removed unused code and extra div<commit_after>
import React, {
  Component,
  PropTypes,
} from 'react';
import classNames from 'classnames';

class FieldMessage extends Component {

  constructor(props) {
    super(props);
    this.setBalloonWidthBound = this.setBalloonWidth.bind(this);
  }

  componentDidMount() {
    this.setBalloonWidth();
    window.addEventListener('resize', this.setBalloonWidthBound);
  }

  componentDidUpdate() {
    this.setBalloonWidth();
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.setBalloonWidthBound);
  }

  setBalloonWidth() {
    if (!this.props.isDisplayed) return;
    this.refs.balloon.style.width = '';
    const fieldEl = this.refs.componentRoot.children[0];
    this.refs.balloon.style.width = `${fieldEl.offsetWidth}px`;
  }

  render() {
    const classes = classNames('fieldMessage', this.props.className);

    const extendedProps = Object.assign({}, this.props, {
      className: classes,
    });

    let balloon;

    if (this.props.isDisplayed) {
      balloon = (
        <div
          ref="balloon"
          className="fieldMessageBalloon"
        >
          {this.props.message}
        </div>
      );
    }

    return (
      <div ref="componentRoot" {...extendedProps}>
        {this.props.children}
        {balloon}
      </div>
{'fraction_non_alphanumeric': 0.13342846949696754, 'fraction_numerical': 0.0021405636817695326, 'mean_word_length': 2.6894736842105265, 'pattern_counts': {'":': 0, '<': 13, '<?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': '7476746', 'n_tokens_mistral': 895, 'n_tokens_neox': 847, 'n_words': 146}