title: How can I send a data to webview by clicking on react native button
body: <p>I have used the componentDidMount method which sending data properly to webview but i want to send data webview when I click on particular react native button. </p>
  
  <p>In this webview is displaying the local html page and in this I'm sending the data to webview and on load event in html page alert the data which sent by react native in this componentdidmount method is succesfully sending data to webview html page but when I'm trying same code in method which saying that <code>this.input</code> is undefined.</p>
  
  <pre><code>   export default class HtmlRender extends Component {
  
     //error:this.input is undefined
     sendData() {
           this.input.postMessage( data )
     }
  
  // This Is working
   componentDidMount(){
           this.input.postMessage( data)
     }
  
  
   render(){
        return (
            &lt;View style={styles.fullContainer}&gt;
                 &lt;View style={styles.webviewBorder}  &gt;
  
                    &lt;WebView
                      ref={(input) =&gt; this.input = input}
                      source={{uri:'file:///android_asset/Page.html'}}
                     /&gt;
                 &lt;/View&gt;
             &lt;View  &gt;
                  &lt;Button  onPress={this.sendData}&gt;
                     &lt;Text&gt;
                        Data
                     &lt;/Text&gt;
                 &lt;/Button&gt;
              &lt;/View&gt;
    &lt;/View  &gt;
  
  )}
  </code></pre>