<commit_before>import { PureComponent } from 'react';
import PropTypes from 'prop-types';

class ScrollTo extends PureComponent {
  // eslint-disable-line react/prefer-stateless-function
  componentWillReceiveProps(nextProps) {
    if (nextProps.target !== this.props.target) {
      setTimeout(this.handleScroll, 150);
    }
  }

  handleFadeOut = (el, intColor) => {
    el.style.backgroundColor = intColor; // eslint-disable-line
  };

  handleFadeIn = el => {
    const initialColor = el.style.backgroundColor;
    el.style.transition = 'background-color 1.5s linear'; // eslint-disable-line
    el.style.backgroundColor = '#fefedc'; // eslint-disable-line
    setTimeout(() => this.handleFadeOut(el, initialColor), 5000);
  };

  handleScroll = () => {
    const { target } = this.props;
    if (target) {
      const targetBox = target.getBoundingClientRect();
      window.scrollTo({
        behavior: 'smooth',
        left: 0,
        top: targetBox.top - 100
      });
      this.handleFadeIn(target);
    }
  };

  render() {<commit_msg>fix: use mount to scroll<commit_after>import { PureComponent } from 'react';
import PropTypes from 'prop-types';

class ScrollTo extends PureComponent {
  // eslint-disable-line react/prefer-stateless-function
  componentDidMount() {
    setTimeout(this.handleScroll, 150);
  }

  handleFadeOut = (el, intColor) => {
    el.style.backgroundColor = intColor; // eslint-disable-line
  };

  handleFadeIn = el => {
    const initialColor = el.style.backgroundColor;
    el.style.transition = 'background-color 1.5s linear'; // eslint-disable-line
    el.style.backgroundColor = '#fefedc'; // eslint-disable-line
    setTimeout(() => this.handleFadeOut(el, initialColor), 5000);
  };

  handleScroll = () => {
    const { target } = this.props;
    if (target) {
      const targetBox = target.getBoundingClientRect();
      window.scrollTo({
        behavior: 'smooth',
        left: 0,
        top: targetBox.top - 100
      });
      this.handleFadeIn(target);
    }
  };

  render() {
{'fraction_non_alphanumeric': 0.13828740157480315, 'fraction_numerical': 0.012795275590551181, 'mean_word_length': 3.0177865612648223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3947341', 'n_tokens_mistral': 666, 'n_tokens_neox': 628, 'n_words': 125}