title: React Native cannot read property undefined error
body: <p>I'm starting out on react native and I'm trying to do a simple console log the value from the text box when a button is pressed.</p>
  
  <p>I am getting the error </p>
  
  <blockquote>
    <p>Cannot read property 'email' of undefined</p>
  </blockquote>
  
  <p>. The error is happening on the console.log. What am I doing wrong here?</p>
  
  <p><strong>LoginPage.js</strong> </p>
  
  <pre><code>import React, {Component} from 'react';
  import {AppRegistry, Text, View, TextInput, Button} from 'react-native';
  
  
  export default class LoginPage extends Component{
    constructor(){
      super()
  
      this.state = {
        email: '',
        password: '',
      }
    }
  
    static navigationOptions = {
      headerTitle: 'Login',
    };
  
    getUser(){
    /*  fetch('http://192.168.1.12:8000/login')
        .then(response =&gt; response.json())
        .then(response =&gt; {
          console.log(response);
        });
    */
      console.log(this.state.email);
      console.log(this.state.password);
    }
  
    render(){
      return(
        &lt;View&gt;
          &lt;Text&gt;Login Page&lt;/Text&gt;
  
  
          &lt;TextInput
            placeholder = "Email"
            onChangeText={(text) =&gt; this.setState({email: text})}
            //value={this.state.textValue}
            //onChangeText={(value) =&gt; this.onChangeText(value)}
            //onSubmitEditing={this.onSubmit}
          /&gt;
  
          &lt;TextInput
            placeholder = "Password"
            secureTextEntry={true}
            onChangeText={(text) =&gt; this.setState({password: text})}
            //value={this.state.textValue}
            //onChangeText={(value) =&gt; this.onChangeText(value)}
            //onSubmitEditing={this.onSubmit}
          /&gt;
  
          &lt;Button
            //onPress={() =&gt; this.props.navigation.navigate('RegisterPage')}
            title="Login"
            accessibilityLabel="Login"
            onPress={this.getUser}
          /&gt;
  
        &lt;/View&gt;
      );
    }
  }
  
  AppRegistry.registerComponent('LoginPage', () =&gt; LoginPage);
  </code></pre>