title: React-Native Error - "[TypeError: undefined is not an object (evaluating '_this2._OnAlert(count)')]"
body: <p>I am trying to build a sample app which pops up an alert displaying the number of objects in the response of an API. The alert pops up once but afterwards, I am getting this error</p>
  
  <pre><code>[TypeError: undefined is not an object (evaluating '_this2._OnAlert(count)')]
  </code></pre>
  
  <p>This is my code</p>
  
  <pre><code>import React from 'react';
  import { View, Button, Alert } from 'react-native';
  import ProductListingItem from './ProductListingItem';
  
  export default class ProductDetailedListingPage extends React.Component {
    constructor() {
      super();
  
   }
  
   _OnAlert(count){
      console.log('_onAlert');
      console.log('count = '+ count);
      Alert.alert(
        'API call success',
        count+' objects',
        [
          {text:'done',onPress: () =&gt; { }}
        ]
      );
    }
  
   _getResponseFromApi(){
      console.log('_getREsponseFromApi called');
      var myRequest = new Request('http://mysampleapi.com:8082/listProducts',);
      myRequest.method = 'GET';
      return fetch(myRequest)
        .then((response)=&gt; response.json())
        .then((responseJson) =&gt; {
          var data = responseJson.error;
          console.log('data = '+data);
          /*console.log(responseJson);*/
          var count = Object.keys(responseJson).length;
           count = '2';
           console.log('count in _getResponseFromApi = '+count);
          this._OnAlert(count);
          return responseJson;
        })
        .catch((error) =&gt; {
          console.log(error);
        });
    }
  
   componentDidMount () {
      console.log('componentDidMount');
      this._getResponseFromApi();
    }
    componentWillMount () {
      console.log('componentWillMount');
    }
  
   render(){
      console.log('render');
      return(
        &lt;View style = {{
          flex:1,
          flexDirection:'column',
        }}&gt;
        &lt;Button style ={{flex:1}}
          onPress ={this._getResponseFromApi}
          title ="Call"
          /&gt;
  
       &lt;/View&gt;
      );
    }
  }
  </code></pre>
  
  <p>The problem is with <code>_OnAlert()</code> , it runs for the first time at <code>componentDidMount()</code> without issues and displays the alert dialog, but at the instance of <code>onPress()</code> it gives me the above mentioned error. I am a noob when it comes to React and Javascript, especially JSX. How can I fix this issue?</p>