title: How to use refs in React with Typescript
body: <p>I'm using Typescript with React. I'm having trouble understanding how to use refs so as to get static typing and intellisense with respect to the react nodes referenced by the refs. My code is as follows.</p>
  
  <pre><code>import * as React from 'react';
  
  interface AppState {
      count: number;
  }
  
  interface AppProps {
      steps: number;
  }
  
  interface AppRefs {
      stepInput: HTMLInputElement;
  }
  
  export default class TestApp extends React.Component&lt;AppProps, AppState&gt; {
  
  constructor(props: AppProps) {
      super(props);
      this.state = {
          count: 0
      };
  }
  
  incrementCounter() {
      this.setState({count: this.state.count + 1});
  }
  
  render() {
      return (
          &lt;div&gt;
              &lt;h1&gt;Hello World&lt;/h1&gt;
              &lt;input type="text" ref="stepInput" /&gt;
              &lt;button onClick={() =&gt; this.incrementCounter()}&gt;Increment&lt;/button&gt;
              Count : {this.state.count}
          &lt;/div&gt;
      );
  }}
  </code></pre>