<commit_before>import React from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import CSSModules from "react-css-modules";
import styles from "./Timer.css";
import Text from "../Text/Text.js";

export class Timer extends React.PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      "secondsRemaining": this.props.time
    };
  }

  componentDidMount() {
    this.interval = setInterval(this._renderTimer, 1000);
  }

  _renderTimer = () => {
    this.setState({ "secondsRemaining": this.state.secondsRemaining - 1 });
    if (this.state.secondsRemaining <= 0) {
      this.setState({
        "secondsRemaining": this.props.time
      });
    }
  };

  render() {
    let { className, style } = this.props;

    return (
      <div style={style} className={cx(className)}>
        <Text>{this.state.secondsRemaining}</Text>
      </div>
    );
  }
}
<commit_msg>Added componentWillUnmount() function to clear the interval. This fixes #786<commit_after>import React from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import CSSModules from "react-css-modules";
import styles from "./Timer.css";
import Text from "../Text/Text.js";

export class Timer extends React.PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      "secondsRemaining": this.props.time
    };
  }

  componentDidMount() {
    this.interval = setInterval(this._renderTimer, 1000);
  }

  componentWillUnmount() {
    clearInterval(this.interval);
  }

  _renderTimer = () => {
    this.setState({ "secondsRemaining": this.state.secondsRemaining - 1 });
    if (this.state.secondsRemaining <= 0) {
      this.setState({
        "secondsRemaining": this.props.time
      });
    }
  };

  render() {
    let { className, style } = this.props;

    return (
      <div style={style} className={cx(className)}>
        <Text>{this.state.secondsRemaining}</Text>
      </div>
    );
  }
}

{'fraction_non_alphanumeric': 0.1456953642384106, 'fraction_numerical': 0.007641365257259297, 'mean_word_length': 3.1002087682672235, 'pattern_counts': {'":': 6, '<': 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': '2312908', 'n_tokens_mistral': 618, 'n_tokens_neox': 598, 'n_words': 131}