Browse Source

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

Thibault Malbranche 5 years ago
parent
commit
4a4ccd8141
No account linked to committer's email address
3 changed files with 14 additions and 15 deletions
  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 View File

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

+ 4
- 7
js/WebView.ios.js View File

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
    * Go forward one page in the web view's history.
298
    * Go forward one page in the web view's history.

+ 1
- 1
package.json View File

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