title: In React Native, how can I access methods of one component from another component?
body: <p>I'm trying to access a method of a React Native component from a different component. It is passed through props. Unfortunately, it seems like the components aren't providing their methods publicly. How can I get access to the method?</p>
  
  <p>Have a look at the following, you'll see InsideView has this.props.myModal, which is a ShowMyModal component. However, it doesn't have access to the .openModal() method.</p>
  
  <p><a href="https://i.stack.imgur.com/UugnQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UugnQ.png" alt="enter image description here"></a></p>
  
  <pre><code>'use strict';
  
  var React = require('react-native');
  var {
    AppRegistry,
    ActionSheetIOS,
    StyleSheet,
    Text,
    View,
  } = React;
  
  var InsideView = React.createClass({
    makeItOpen: function() {
      debugger;
      this.props.myModal.openModal();
    },
  
    render: function() {
      return (
        &lt;View&gt;
          &lt;Text onPress={() =&gt; this.makeItOpen()}&gt;Click me!&lt;/Text&gt;
        &lt;/View&gt;
      );
    }
  });
  
  var ShowMyModal = React.createClass({
    getInitialState: function() {
      return {
        isModalOpen: false,
      }
    },
  
    openModal() {
      this.setState({isModalOpen: true});
    },
  
    closeModal() {
      this.setState({isModalOpen: false});
    },
  
    render: function() {
      return (
        &lt;Text&gt;isModalOpen = {String(this.state.isModalOpen)}&lt;/Text&gt;
      );
    }
  });
  
  var AwesomeProject = React.createClass({
    getInitialState: function() {
      return {
        myModal: &lt;ShowMyModal /&gt;,
      }
    },
  
    render: function() {
      return (
        &lt;View style={{padding: 30}}&gt;
          &lt;InsideView myModal={this.state.myModal}/&gt;
          {this.state.myModal}
        &lt;/View&gt;
      );
    },
  });
  
  AppRegistry.registerComponent('AwesomeProject', () =&gt; AwesomeProject);
  </code></pre>