title: Using state in react with TypeScript
body: <p>I am new to TypeScript. I've got a problem with displaying <code>this.state.something</code> inside the render method or assigning it to a variable inside a function.</p>
  <p>Have a look at the most important piece of code:</p>
  <pre><code>interface State {
      playOrPause?: string;
  }
  
  class Player extends React.Component {
      constructor() {
          super();
  
          this.state = {
              playOrPause: 'Play'
          };
      }
  
      render() {
          return(
              &lt;div&gt;
                  &lt;button
                      ref={playPause =&gt; this.playPause = playPause}
                      title={this.state.playOrPause} // in this line I get an error
                      &gt;
                      Play
                  &lt;/button&gt;
             &lt;/div&gt;
          );
      }
  }
  </code></pre>
  <p>The errors says: <code>[ts] Property 'playOrPause' does not exist on type 'ReadOnly&lt;{}&gt;'.</code></p>
  <p>I tried to declare the playOrPause property to be a type of string and it didn't work.</p>
  <p>What am I missing here to make it work?</p>