<commit_before>import React from 'react';
import Elements from '../../api/elements.js';
import InplaceEdit from '../components/inplace-edit.jsx';

export default class ElementName extends React.Component {
  constructor(props) {
    super(props);
    this.setName = this.setName.bind(this);
  }

  setName(text) {
    Elements.setName(this.props.elementId, text);
    this.setState({ editing: false });
  }

  render() {
    let elementName;
    if (this.props.elementName.length === 0) {
      elementName = 'name';
    } else {
      elementName = this.props.elementName;
    }

    return (
      <div
        className="elementName"
        style= {{ display: 'inline-block' }}
      >
        <InplaceEdit onChange={this.setName} text={elementName} />
      </div>
    );
  }
}

ElementName.propTypes = {
  elementName: React.PropTypes.string.isRequired,
  elementId: React.PropTypes.string.isRequired,
};<commit_msg>Change react component to stateless function<commit_after>import React from 'react';
import Elements from '../../api/elements.js';
import InplaceEdit from '../components/inplace-edit.jsx';

const setName = (elementId, text) => {
  Elements.setName(elementId, text);
};

const elementName = (name) => {
  if (name.length === 0) {
    return 'name';
  }
  return name;
};

const ElementName = (props) => (
  <div
    className="elementName"
    style={{ display: 'inline-block' }}
  >
    <InplaceEdit
      onChange={(text) => setName(props.elementId, text)}
      text={elementName(props.elementName)}
    />
  </div>
);

ElementName.propTypes = {
  elementName: React.PropTypes.string.isRequired,
  elementId: React.PropTypes.string.isRequired,
};

export default ElementName;
{'fraction_non_alphanumeric': 0.1483225426721601, 'fraction_numerical': 0.0011771630370806356, 'mean_word_length': 3.336734693877551, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5989690', 'n_tokens_mistral': 537, 'n_tokens_neox': 533, 'n_words': 109}