Skip to content

Commit

Permalink
fix(iOS/android getViewManagerConfig): Fix crash with react-native < …
Browse files Browse the repository at this point in the history
…0.58
  • Loading branch information
Titozzz committed Feb 5, 2019
1 parent a4c6f21 commit 263fc5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion js/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,14 @@ class WebView extends React.Component<WebViewSharedProps, State> {
);
}

getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
getViewManagerConfig = viewManagerName => {
if (!UIManager.getViewManagerConfig) {
return UIManager[viewManagerName];
}
return UIManager.getViewManagerConfig(viewManagerName);
};

getCommands = () => this.getViewManagerConfig('RNCWebView').Commands;

goForward = () => {
UIManager.dispatchViewManagerCommand(
Expand Down
11 changes: 9 additions & 2 deletions js/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,17 @@ class WebView extends React.Component<WebViewSharedProps, State> {
);
}

_getViewManagerConfig = viewManagerName => {
if (!UIManager.getViewManagerConfig) {
return UIManager[viewManagerName];
}
return UIManager.getViewManagerConfig(viewManagerName);
};

_getCommands = () =>
!this.props.useWebKit
? UIManager.getViewManagerConfig('RNCUIWebView').Commands
: UIManager.getViewManagerConfig('RNCWKWebView').Commands;
? this._getViewManagerConfig('RNCUIWebView').Commands
: this._getViewManagerConfig('RNCWKWebView').Commands;

/**
* Go forward one page in the web view's history.
Expand Down

0 comments on commit 263fc5e

Please sign in to comment.