title: Uncaught TypeError: Cannot read property 'state or props' of undefined
body: <p>So I started converting my application from ES2015 to ES6 which uses React.</p>
  
  <p>I have a parent class and a child class like so,</p>
  
  <pre><code>export default class Parent extends Component {
      constructor(props) {
          super(props);
          this.state = {
              code: ''
          };
      }
  
      setCodeChange(newCode) {
          this.setState({code: newCode});
      }
  
  
      login() {
          if (this.state.code == "") {
              // Some functionality
          }
      }
  
      render() {
          return (
              &lt;div&gt;
                  &lt;Child onCodeChange={this.setCodeChange} onLogin={this.login} /&gt;
              &lt;/div&gt;
          );
      }
  }
  </code></pre>
  
  <p>Child class,</p>
  
  <pre><code>export default class Child extends Component {
      constructor(props) {
          super(props);
      }
  
      handleCodeChange(e) {
          this.props.onCodeChange(e.target.value);
      }
  
      login() {
          this.props.onLogin();
      }
  
      render() {
          return (
              &lt;div&gt;
                  &lt;input name="code" onChange={this.handleCodeChange.bind(this)}/&gt;
              &lt;/div&gt;
              &lt;button id="login" onClick={this.login.bind(this)}&gt;
          );
      }
  }
  
  Child.propTypes = {
      onCodeChange: React.PropTypes.func,
      onLogin: React.PropTypes.func
  };
  </code></pre>
  
  <p>However this causes the following error,</p>
  
  <p><strong>this.state is undefined</strong></p>
  
  <p>It refers to,</p>
  
  <pre><code>if (this.state.code == "") {
      // Some functionality
  }
  </code></pre>
  
  <p>Any idea what could be causing this ?</p>