Parcourir la source

make it possible to get WebView's reference

Hleb Barylskyi il y a 7 ans
Parent
révision
89bbccc2f3
No account linked to committer's email address
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 4
    2
      autoHeightWebView/index.ios.js

+ 4
- 2
autoHeightWebView/index.ios.js Voir le fichier

@@ -34,6 +34,7 @@ export default class AutoHeightWebView extends PureComponent {
34 34
         onLoadStart: PropTypes.func,
35 35
         onLoadEnd: PropTypes.func,
36 36
         onShouldStartLoadWithRequest: PropTypes.func,
37
+        _ref: PropTypes.func,
37 38
         // add web/files... to project root
38 39
         files: PropTypes.arrayOf(PropTypes.shape({
39 40
             href: PropTypes.string,
@@ -136,7 +137,7 @@ export default class AutoHeightWebView extends PureComponent {
136 137
 
137 138
     render() {
138 139
         const { height, script } = this.state;
139
-        const { onError, onLoad, onLoadStart, onLoadEnd, onShouldStartLoadWithRequest, scalesPageToFit, enableAnimation, source, heightOffset, customScript, style } = this.props;
140
+        const { _ref, onError, onLoad, onLoadStart, onLoadEnd, onShouldStartLoadWithRequest, scalesPageToFit, enableAnimation, source, heightOffset, customScript, style } = this.props;
140 141
         const webViewSource = Object.assign({}, source, { baseUrl: 'web/' });
141 142
         return (
142 143
             <Animated.View style={[Styles.container, {
@@ -144,6 +145,7 @@ export default class AutoHeightWebView extends PureComponent {
144 145
                 height: height + heightOffset,
145 146
             }, style]}>
146 147
                 <WebView
148
+                    ref={_ref}
147 149
                     onError={onError}
148 150
                     onLoad={onLoad}
149 151
                     onLoadStart={onLoadStart}
@@ -215,4 +217,4 @@ const IframeBaseScript =
215 217
         window.addEventListener('load', updateHeight);
216 218
         window.addEventListener('resize', updateHeight);
217 219
     } ());
218
-    `;
220
+    `;