diff --git a/js/WebView.android.js b/js/WebView.android.js index defef94..3c6d22f 100644 --- a/js/WebView.android.js +++ b/js/WebView.android.js @@ -194,10 +194,12 @@ class WebView extends React.Component { ); } + getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands; + goForward = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.goForward, + this.getCommands().goForward, null, ); }; @@ -205,7 +207,7 @@ class WebView extends React.Component { goBack = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.goBack, + this.getCommands().goBack, null, ); }; @@ -216,7 +218,7 @@ class WebView extends React.Component { }); UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.reload, + this.getCommands().reload, null, ); }; @@ -224,7 +226,7 @@ class WebView extends React.Component { stopLoading = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.stopLoading, + this.getCommands().stopLoading, null, ); }; @@ -232,7 +234,7 @@ class WebView extends React.Component { postMessage = (data: string) => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.postMessage, + this.getCommands().postMessage, [String(data)], ); }; @@ -246,7 +248,7 @@ class WebView extends React.Component { injectJavaScript = (data: string) => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.injectJavaScript, + this.getCommands().injectJavaScript, [data], ); }; @@ -311,7 +313,7 @@ class WebView extends React.Component { if (shouldStart) { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RNCWebView.Commands.loadUrl, + this.getCommands().loadUrl, [String(url)], ); } diff --git a/js/WebView.ios.js b/js/WebView.ios.js index 88adb79..6cb2cee 100644 --- a/js/WebView.ios.js +++ b/js/WebView.ios.js @@ -289,13 +289,10 @@ class WebView extends React.Component { ); } - _getCommands() { - if (!this.props.useWebKit) { - return UIManager.RNCUIWebView.Commands; - } - - return UIManager.RNCWKWebView.Commands; - } + _getCommands = () => + !this.props.useWebKit + ? UIManager.getViewManagerConfig('RNCUIWebView').Commands + : UIManager.getViewManagerConfig('RNCWKWebView').Commands; /** * Go forward one page in the web view's history. diff --git a/package.json b/package.json index 1abea80..8639d33 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "flow-bin": "^0.80.0", "jest": "^24.0.0", "metro-react-native-babel-preset": "^0.51.1", - "react-native": "^0.57", + "react-native": ">=0.57 <0.59", "semantic-release": "15.10.3" }, "repository": {