title: How to setInterval in React with Typescript
body: <p>I'm trying to render a dynamic progress bar in react/typescript. I was able to do this in react but converting this into typescript gives me;</p>
  
  <blockquote>
    <p>[ts] Property 'setInterval' does not exist on type 'Jockey'.
    any</p>
  </blockquote>
  
  <p>with a warning underline on <code>setInterval</code> call inside <code>componentDidMount</code>.</p>
  
  <p>With react only I used <code>this.interval = setInterval(this.timer, this.state.interval);</code> inside <code>componentDidMount</code>and it worked but with typescript's strict typing I'm not sure how to do this.</p>
  
  <p><strong>Jockey.tsx</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import * as React from 'react';
  
  interface Props {
      color: string;
      avatar: string;
  }
  
  interface State {
      interval: number;
      progress: number;
  }
  
  export class Jockey extends React.Component&lt;Props, State&gt; {
  
      constructor(props: Props) {
          super(props);
          this.state = {
            interval: Math.floor(Math.random() * 500),
            progress: 0,
          };
      }
  
      componentDidMount () {
          this.setInterval(this.timer, this.state.interval);
      }
  
      timer () {
          this.setState({ progress: this.state.progress + 1 });
          console.log('anyhting');
          
          (this.state.progress &gt;= 99) ? this.setState({ progress: 100 }) : this.setState({ progress: 0 }) ;
      }
  
      render() {
          return (
              &lt;div&gt;
                  &lt;div className="App-lane"&gt;
                      {/* &lt;img src={ this.props.avatar } alt=""/&gt; */}
                      &lt;progress value={this.state.progress} color={this.props.color} max="100" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          );
      }
  }</code></pre>
  </div>
  </div>
  </p>