<commit_before>import React from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import { default as Dp } from "react-datepicker";
import moment from "moment";

class DatePicker extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      "startDate": moment(this.props.selected)|| moment()
    };
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(date, event) {
    event.persist();
    this.setState({
      "startDate": date
    });
    if (typeof this.props.onChange !== "undefined") {
      this.props.onChange(date, event, true);
    }
  }

  componentWillReceiveProps(nextProps) {
    console.log("CWRP: ", nextProps)
    if (
      typeof nextProps.selected !== "undefined" &&
      nextProps.selected !== this.state.selected
    ) {
      this.setState({ "startDate": moment(nextProps.selected) });
    }
  }

  render() {
    let { format, name, className, style } = this.props;
    return (
      <Dp
        style={style}
        className={cx(className, "ra_DatePicker__datepicker")}
        name={name}
        dateFormat={format}
        selected={this.state.startDate}
        onChange={this.handleChange}
      />
    );
  }
}

DatePicker.propTypes = {
  "name": PropTypes.string,
  "format": PropTypes.string,
  "value": PropTypes.string,
  "onChange": PropTypes.func,
  /**
   * The currently selected Date.  You can use any format accepted by Moment.js
   */
  "selected": PropTypes.string,
  /**
   * Pass inline styles here.
   */
  "style": PropTypes.object,
  /*
   * An Object, array, or string of CSS classes to apply to DatePicker.
   */
  "className": PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.object,
    PropTypes.array
  ])
};

export default DatePicker;
<commit_msg>Update DatePicker.js<commit_after>import React from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import { default as Dp } from "react-datepicker";
import moment from "moment";

class DatePicker extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      "startDate": moment(this.props.selected)|| moment()
    };
    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(date, event) {
    event.persist();
    this.setState({
      "startDate": date
    });
    if (typeof this.props.onChange !== "undefined") {
      this.props.onChange(date, event, true);
    }
  }

  componentWillReceiveProps(nextProps) {
    if (
      typeof nextProps.selected !== "undefined" &&
      nextProps.selected !== this.state.selected
    ) {
      this.setState({ "startDate": moment(nextProps.selected) });
    }
  }

  render() {
    let { format, name, className, style } = this.props;
    return (
      <Dp
        style={style}
        className={cx(className, "ra_DatePicker__datepicker")}
        name={name}
        dateFormat={format}
        selected={this.state.startDate}
        onChange={this.handleChange}
      />
    );
  }
}

DatePicker.propTypes = {
  "name": PropTypes.string,
  "format": PropTypes.string,
  "value": PropTypes.string,
  "onChange": PropTypes.func,
  /**
   * The currently selected Date.  You can use any format accepted by Moment.js
   */
  "selected": PropTypes.string,
  /**
   * Pass inline styles here.
   */
  "style": PropTypes.object,
  /*
   * An Object, array, or string of CSS classes to apply to DatePicker.
   */
  "className": PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.object,
    PropTypes.array
  ])
};

export default DatePicker;

{'fraction_non_alphanumeric': 0.13189771197846567, 'fraction_numerical': 0.0, 'mean_word_length': 2.532319391634981, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 5, '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': '5103543', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1113, 'n_words': 247}