Bladeren bron

fix(android/iOS): Fixed react-native 0.58 warnings (#311)

Thibault Malbranche 5 jaren geleden
bovenliggende
commit
4a4ccd8141
No account linked to committer's email address
3 gewijzigde bestanden met toevoegingen van 14 en 15 verwijderingen
  1. 9
    7
      js/WebView.android.js
  2. 4
    7
      js/WebView.ios.js
  3. 1
    1
      package.json

+ 9
- 7
js/WebView.android.js Bestand weergeven

@@ -194,10 +194,12 @@ class WebView extends React.Component<WebViewSharedProps, State> {
194 194
     );
195 195
   }
196 196
 
197
+  getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
198
+
197 199
   goForward = () => {
198 200
     UIManager.dispatchViewManagerCommand(
199 201
       this.getWebViewHandle(),
200
-      UIManager.RNCWebView.Commands.goForward,
202
+      this.getCommands().goForward,
201 203
       null,
202 204
     );
203 205
   };
@@ -205,7 +207,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
205 207
   goBack = () => {
206 208
     UIManager.dispatchViewManagerCommand(
207 209
       this.getWebViewHandle(),
208
-      UIManager.RNCWebView.Commands.goBack,
210
+      this.getCommands().goBack,
209 211
       null,
210 212
     );
211 213
   };
@@ -216,7 +218,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
216 218
     });
217 219
     UIManager.dispatchViewManagerCommand(
218 220
       this.getWebViewHandle(),
219
-      UIManager.RNCWebView.Commands.reload,
221
+      this.getCommands().reload,
220 222
       null,
221 223
     );
222 224
   };
@@ -224,7 +226,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
224 226
   stopLoading = () => {
225 227
     UIManager.dispatchViewManagerCommand(
226 228
       this.getWebViewHandle(),
227
-      UIManager.RNCWebView.Commands.stopLoading,
229
+      this.getCommands().stopLoading,
228 230
       null,
229 231
     );
230 232
   };
@@ -232,7 +234,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
232 234
   postMessage = (data: string) => {
233 235
     UIManager.dispatchViewManagerCommand(
234 236
       this.getWebViewHandle(),
235
-      UIManager.RNCWebView.Commands.postMessage,
237
+      this.getCommands().postMessage,
236 238
       [String(data)],
237 239
     );
238 240
   };
@@ -246,7 +248,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
246 248
   injectJavaScript = (data: string) => {
247 249
     UIManager.dispatchViewManagerCommand(
248 250
       this.getWebViewHandle(),
249
-      UIManager.RNCWebView.Commands.injectJavaScript,
251
+      this.getCommands().injectJavaScript,
250 252
       [data],
251 253
     );
252 254
   };
@@ -311,7 +313,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
311 313
     if (shouldStart) {
312 314
       UIManager.dispatchViewManagerCommand(
313 315
         this.getWebViewHandle(),
314
-        UIManager.RNCWebView.Commands.loadUrl,
316
+        this.getCommands().loadUrl,
315 317
         [String(url)],
316 318
       );
317 319
     }

+ 4
- 7
js/WebView.ios.js Bestand weergeven

@@ -289,13 +289,10 @@ class WebView extends React.Component<WebViewSharedProps, State> {
289 289
     );
290 290
   }
291 291
 
292
-  _getCommands() {
293
-    if (!this.props.useWebKit) {
294
-      return UIManager.RNCUIWebView.Commands;
295
-    }
296
-
297
-    return UIManager.RNCWKWebView.Commands;
298
-  }
292
+  _getCommands = () =>
293
+    !this.props.useWebKit
294
+      ? UIManager.getViewManagerConfig('RNCUIWebView').Commands
295
+      : UIManager.getViewManagerConfig('RNCWKWebView').Commands;
299 296
 
300 297
   /**
301 298
    * Go forward one page in the web view's history.

+ 1
- 1
package.json Bestand weergeven

@@ -37,7 +37,7 @@
37 37
     "flow-bin": "^0.80.0",
38 38
     "jest": "^24.0.0",
39 39
     "metro-react-native-babel-preset": "^0.51.1",
40
-    "react-native": "^0.57",
40
+    "react-native": ">=0.57 <0.59",
41 41
     "semantic-release": "15.10.3"
42 42
   },
43 43
   "repository": {