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

import './HelloWorldPage.css';

export default class extends Component {
  static propTypes = {
    initialName: PropTypes.string
  }

  static defaultProps = {
    initialName: 'Аноним'
  };

  state = {
    name:            this.props.initialName,
    touched:         false,
    greetingWidget:  () => null
  };

  handleNameChange = (val) => {
    const name = val.target.value;

    this.setState({ touched: true });

    if (name.length === 0) {
      this.setState({ name: this.props.initialName });
    } else {
      this.setState({ name });
    }
  };

  renderGreetingWidget = () => (!this.state.touched ? null :
    <div>
      <hr />
      <p>Здравствуйте, {this.state.name}!</p>
    </div>
  );

  render() {
    return (
      <div className='App'>
        <h1>Hello World!</h1>
        <div>
          <p>Введите Ваше имя:</p>
          <div><input onChange={this.handleNameChange} /></div>
          {this.renderGreetingWidget()}
        </div>
      </div>
    );
  }
}<commit_msg>component coding style<commit_after>import React, { PropTypes, Component } from 'react';

import './HelloWorldPage.css';

const propTypes = {
  initialName: PropTypes.string
};

const defaultProps = {
  initialName: 'Аноним'
};

class HelloWorldPage extends Component {
  constructor(props) {
    super(props);

    this.handleNameChange = this.handleNameChange.bind(this);
    this.renderGreetingWidget = this.renderGreetingWidget.bind(this);

    this.state = {
      name:            this.props.initialName,
      touched:         false,
      greetingWidget:  () => null
    };
  }

  handleNameChange(val) {
    const name = val.target.value;

    this.setState({ touched: true });

    if (name.length === 0) {
      this.setState({ name: this.props.initialName });
    } else {
      this.setState({ name });
    }
  }

  renderGreetingWidget() {
    if (!this.state.touched) {
      return null;
    }

    return (
      <div>
        <hr />
        <p>Здравствуйте, {this.state.name}!</p>
      </div>
    );
  }

  render() {
    return (
      <div className='App'>
        <h1>Hello World!</h1>
        <div>
          <p>Введите Ваше имя:</p>
          <div><input onChange={this.handleNameChange} /></div>
          {this.renderGreetingWidget()}
        </div>
      </div>
    );
  }
}

HelloWorldPage.propTypes = propTypes;
HelloWorldPage.defaultProps = defaultProps;

export default HelloWorldPage;
{'fraction_non_alphanumeric': 0.14814814814814814, 'fraction_numerical': 0.0024154589371980675, 'mean_word_length': 2.317757009345794, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, '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': '5621740', 'n_tokens_mistral': 816, 'n_tokens_neox': 823, 'n_words': 154}