title: How to call a function from another function in React-Native?
body: <p>This might be an easy question, but I'm new to React-Native and I'm totally stuck right now.</p>
  
  <p>How do I call function2 from function1?</p>
  
  <p>This is what I've tried, but when pressing the first button it renders an error that says:</p>
  
  <blockquote>
    <p>Undefined is not a function (evaluating 'this.function2()')</p>
  </blockquote>
  
  <pre><code>import React, { Component } from 'react';
  import {
  AppRegistry,
  View,
  Image,
  TouchableOpacity,
  } from 'react-native';
  
  export default class Example extends Component {
  
      function1(){
          console.log('function1() called');
          ...
          this.function2();
      };
  
      function2() {
          console.log('function2() called');
          ...
      };
  
      render() {
          return (
              &lt;View&gt;
                  &lt;TouchableOpacity onPress={this.function1}&gt;
                      &lt;Image source={require('../../../assets/img/button.png')} /&gt;
                  &lt;/TouchableOpacity&gt;
  
                  &lt;TouchableOpacity onPress={this.function2}&gt;
                      &lt;Image source={require('../../../assets/img/button.png')} /&gt;
                  &lt;/TouchableOpacity&gt;
              &lt;/View&gt;
          );
      };
  }
  
  AppRegistry.registerComponent('Example', () =&gt; Example);
  </code></pre>