title: TSX + React: Uncaught TypeError: Cannot read property 'setState' of undefined at Menu.handleClick
body: <p>I am using typescript@2.6.1 and react and react-dom @15.6.2.</p>
  
  <p>I can't seem to debug this issue:
  Uncaught TypeError: Cannot read property 'setState' of undefined  at Menu.handleClick.
  This is at <code>this.setState( (prevState) =&gt; {</code></p>
  
  <pre><code>import * as React from "react";
  import * as ReactDOM from 'react-dom';
  
  import Monaco from './Monaco';
  import shiftOverlayButtons from '../common/shiftOverlayButtons';
  
  export interface Props {
  
  }
  
  export interface State {
      isOpen: boolean;
  }
  
  export default class Menu extends React.Component&lt;Props, State&gt; {
  
      constructor(props: Props) {
          super(props);
      }
      public state: State = {
          isOpen: false
        };
  
      public render() {
          return &lt;button id="overlay-btn" className="menu-btn" onClick={this.handleClick}&gt;&lt;/button&gt;
      }
  
      public handleClick(): void {
          this.setState( (prevState) =&gt; {
              if(prevState.isOpen === false){
                  this.openMenu();
                  return {
                      isOpen: true
                  };
              }
              else {
                  this.closeMenu();
                  return {
                      isOpen: false
                  }
              }
          });
      }
  
      private openMenu(): void {
          shiftOverlayButtons(true);
          ReactDOM.render(&lt;Monaco/&gt;, document.getElementById("overlay"));
      }
  
      private closeMenu(): void {
          shiftOverlayButtons(false);
          //ReactDOM.unmountComponentAtNode(document.getElementById("overlay"));
      }
  
  }
  
  ReactDOM.render(&lt;Menu/&gt;, document.body);
  </code></pre>
  
  <p>PS: When I do <code>this.handleClick.bind(this)</code> I get another error: GET file:///Users/kalpa/Desktop/monaco-sample/vs/loader.js net::ERR_FILE_NOT_FOUND ... I am using webpack @3.8.1</p>