Browse Source

Merge pull request #37 from Barylskyigb/patch-1

Make it possible to use stopLoading function of react-native's WebView
iou90 6 years ago
parent
commit
d0f7f26840
No account linked to committer's email address
2 changed files with 13 additions and 0 deletions
  1. 8
    0
      autoHeightWebView/index.android.js
  2. 5
    0
      autoHeightWebView/index.ios.js

+ 8
- 0
autoHeightWebView/index.android.js View File

@@ -273,6 +273,14 @@ export default class AutoHeightWebView extends PureComponent {
273 273
     onLoadEnd && onLoadEnd(event);
274 274
   };
275 275
 
276
+  stopLoading() {
277
+    UIManager.dispatchViewManagerCommand(
278
+      findNodeHandle(this.webview),
279
+      UIManager.RCTAutoHeightWebView.Commands.stopLoading,
280
+      null
281
+    );
282
+  }
283
+
276 284
   render() {
277 285
     const { height, script, isChangingSource, heightOffset } = this.state;
278 286
     const {

+ 5
- 0
autoHeightWebView/index.ios.js View File

@@ -134,6 +134,10 @@ export default class AutoHeightWebView extends PureComponent {
134 134
         }
135 135
     }
136 136
 
137
+    stopLoading() {
138
+        this.webview.stopLoading();   
139
+    }
140
+
137 141
     render() {
138 142
         const { height, script } = this.state;
139 143
         const { onError, onLoad, onLoadStart, onLoadEnd, onShouldStartLoadWithRequest, scalesPageToFit, enableAnimation, source, heightOffset, customScript, style } = this.props;
@@ -144,6 +148,7 @@ export default class AutoHeightWebView extends PureComponent {
144 148
                 height: height + heightOffset,
145 149
             }, style]}>
146 150
                 <WebView
151
+                    ref={webview => this.webview = webview}
147 152
                     onError={onError}
148 153
                     onLoad={onLoad}
149 154
                     onLoadStart={onLoadStart}