title: Using setInterval in React Component
body: <p>I was reading the tutorial on the official react website. In the example about life cycle methods, under the componentDidMount method, a timerID is set to the setInterval function. </p>
  
  <p>My question is even though the timerID was initialized, it was never called throughout the application, how does the application work without explicitly calling timerID anywhere in the application. Here is the code below.</p>
  
  <pre><code>class Clock extends React.Component {
    constructor(props) {
      super(props);
      this.state = {date: new Date()};
    }
  
    componentDidMount() {
      this.timerID = setInterval(
        () =&gt; this.tick(),
        1000
      );
    }
  
    componentWillUnmount() {
      clearInterval(this.timerID);
    }
  
    tick() {
      this.setState({
        date: new Date()
      });
    }
  
    render() {
      return (
        &lt;div&gt;
          &lt;h1&gt;Hello, world!&lt;/h1&gt;
          &lt;h2&gt;It is {this.state.date.toLocaleTimeString()}.&lt;/h2&gt;
        &lt;/div&gt;
      );
    }
  }
  
  ReactDOM.render(
    &lt;Clock /&gt;,
    document.getElementById('root')
  
  );
  </code></pre>