Browse Source

make it possible to get WebView's reference

Hleb Barylskyi 7 years ago
parent
commit
89bbccc2f3
No account linked to committer's email address
1 changed files with 4 additions and 2 deletions
  1. 4
    2
      autoHeightWebView/index.ios.js

+ 4
- 2
autoHeightWebView/index.ios.js View File

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