Ver código fonte

Changed ref to use react.createRef

Thibault Malbranche 6 anos atrás
pai
commit
56650cfe5c
1 arquivos alterados com 4 adições e 4 exclusões
  1. 4
    4
      js/WebView.android.js

+ 4
- 4
js/WebView.android.js Ver arquivo

@@ -39,8 +39,6 @@ import type {
39 39
 
40 40
 const resolveAssetSource = Image.resolveAssetSource;
41 41
 
42
-const RCT_WEBVIEW_REF = 'webview';
43
-
44 42
 const WebViewState = keyMirror({
45 43
   IDLE: null,
46 44
   LOADING: null,
@@ -78,6 +76,8 @@ class WebView extends React.Component<WebViewSharedProps, State> {
78 76
     startInLoadingState: true,
79 77
   };
80 78
 
79
+  webViewRef = React.createRef();
80
+
81 81
   UNSAFE_componentWillMount() {
82 82
     if (this.props.startInLoadingState) {
83 83
       this.setState({ viewState: WebViewState.LOADING });
@@ -139,7 +139,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
139 139
 
140 140
     const webView = (
141 141
       <NativeWebView
142
-        ref={RCT_WEBVIEW_REF}
142
+        ref={this.webViewRef}
143 143
         key="webViewKey"
144 144
         style={webViewStyles}
145 145
         source={resolveAssetSource(source)}
@@ -252,7 +252,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
252 252
   };
253 253
 
254 254
   getWebViewHandle = () => {
255
-    return ReactNative.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
255
+    return ReactNative.findNodeHandle(this.webViewRef.current);
256 256
   };
257 257
 
258 258
   onLoadingStart = (event: WebViewNavigationEvent) => {