title: Why this.state is undefined in react native?
body: <p>I am a complete newbie in react native, react.js, and javascript. I am Android developer so would like to give RN a try. </p>
  
  <p>Basically, the difference is in <code>onPress</code>;</p>
  
  <p>This code shows <code>'undefined'</code> when toggle() runs: </p>
  
  <pre><code>class LoaderBtn extends Component {
      constructor(props) {
          super(props);
          this.state = { loading: false };
      }
  
      toggle() {
          console.log(this.state);
          // let state = this.state.loading;
          console.log("Clicked!")
          // this.setState({ loading: !state })
      }
  
      render() {
          return (
              &lt;Button style={{ backgroundColor: '#468938' }} onPress={this.toggle}&gt;
                  &lt;Text&gt;{this.props.text}&lt;/Text&gt;
              &lt;/Button&gt;
          );
      }
  }
  </code></pre>
  
  <p>but this code works: </p>
  
  <pre><code>class LoaderBtn extends Component {
      constructor(props) {
          super(props);
          this.state = { loading: false };
      }
  
      toggle() {
          console.log(this.state);
          // let state = this.state.loading;
          console.log("Clicked!")
          // this.setState({ loading: !state })
      }
  
      render() {
          return (
              &lt;Button style={{ backgroundColor: '#468938' }} onPress={() =&gt; {this.toggle()}}&gt;
                  &lt;Text&gt;{this.props.text}&lt;/Text&gt;
              &lt;/Button&gt;
          );
      }
  }
  </code></pre>
  
  <p>Can you explain me the difference, please? </p>
  
  <p>In Java / Kotlin we have method references, basically it passes the function if signatures are the same, like <code>onPress = () =&gt; {}</code> and <code>toggle = () =&gt; {}</code></p>
  
  <p>But in JS it doesn't work :(</p>