title: Calling a Android Native UI component method from React native Js code
body: <p>I have created a CustomView SignatureView.java which extends LinearLayout for capturing signature in Android Native.</p>
  
  <p>And created SignatureCapturePackage.java and SignatureCaptureViewManager.java</p>
  
  <pre><code>public class SignatureCaptureMainView extends LinearLayout {
  
       .... 
  
      public void saveImage(){
                 //Save image to file 
       }
  }
  </code></pre>
  
  <p>this the Package class</p>
  
  <pre><code>public class SignatureCapturePackage implements ReactPackage {
        private Activity mCurrentActivity;
  
        public RSSignatureCapturePackage(Activity activity) {
          mCurrentActivity = activity;
        }
  
        @Override
        public List&lt;NativeModule&gt; createNativeModules(ReactApplicationContext reactContext) {
          return Arrays.&lt;NativeModule&gt;asList();
        }
  
        @Override
        public List&lt;ViewManager&gt; createViewManagers(ReactApplicationContext reactApplicationContext) {
          return Arrays.&lt;ViewManager&gt;asList(new SignatureCaptureViewManager(mCurrentActivity));
        }
  
        @Override
        public List&lt;Class&lt;? extends JavaScriptModule&gt;&gt; createJSModules() {
          return Arrays.asList();
        }
      }
  </code></pre>
  
  <p>this is the ViewManager class</p>
  
  <pre><code> public class SignatureCaptureViewManager extends      ViewGroupManager&lt;SignatureCaptureMainView&gt; {
      private Activity mCurrentActivity;
  
      public static final String PROPS_SAVE_IMAGE_FILE="saveImageFileInExtStorage";
      public static final String PROPS_VIEW_MODE = "viewMode";
  
      public RSSignatureCaptureViewManager(Activity activity) {
          mCurrentActivity = activity;
      }
  
      @Override
      public String getName() {
          return "SignatureView";
      }
  
      @ReactProp(name = PROPS_SAVE_IMAGE_FILE)
      public void setSaveImageFileInExtStorage(SignatureCaptureMainView view, @Nullable Boolean saveFile) {
          Log.d("React View manager setSaveFileInExtStorage:", "" + saveFile);
          if(view!=null){
              view.setSaveFileInExtStorage(saveFile);
          }
      }
  
      @ReactProp(name = PROPS_VIEW_MODE)
      public void setViewMode(SignatureCaptureMainView view, @Nullable String viewMode) {
          Log.d("React View manager setViewMode:", "" + viewMode);
          if(view!=null){
              view.setViewMode(viewMode);
          }
      }
  
      @Override
      public SignatureCaptureMainView createViewInstance(ThemedReactContext context) {
          Log.d("React"," View manager createViewInstance:");
          return new SignatureCaptureMainView(context, mCurrentActivity);
      }
  
  
    }
  </code></pre>
  
  <p>This is Signature.js bundle </p>
  
  <pre><code>var React = require('react-native');
    var {
      PropTypes,
      requireNativeComponent,
      View,
    } = React;
  
    class SignatureCapture extends React.Component {
  
      constructor() {
        super();
        this.onChange = this.onChange.bind(this);
      }
  
      onChange(event) {
        console.log("Signature  ON Change Event");
        if (!this.props.onSaveEvent) {
          return;
        }
  
        this.props.onSaveEvent({
          pathName: event.nativeEvent.pathName,
          encoded: event.nativeEvent.encoded,
        });
      }
  
      render() {
        return (
          &lt;SignatureView {...this.props} style={{flex: 1}} onChange={this.onChange} /&gt;
        );
      }
  
      save(){
  
      }
    }
  
    SignatureCapture.propTypes = {
      ...View.propTypes,
      saveImageFileInExtStorage: PropTypes.bool,
      viewMode:PropTypes.string
    };
  
    var SignatureView = requireNativeComponent('SignatureView', SignatureCapture, {
      nativeOnly: {onChange: true}
    });
  
    module.exports = SignatureCapture;
  </code></pre>
  
  <p>I am using the Module in ReactNative like this</p>
  
  <pre><code>&lt;SignatureCapture
                  onSaveEvent={this._onSaveEvent}
                  saveImageFileInExtStorage={false}
                  viewMode={"portrait"}/&gt;
  </code></pre>
  
  <p>Everything worksFine. But i have to save the image only when some click event occurs in the react side. ie, i have to call SignatureCaptureMainView's saveImage() method from reactnative js code.</p>
  
  <p>How can i achieve it ?.Please help</p>