Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebView] Add props for overriding native component #10946

Closed
wants to merge 13 commits into from
Closed
17 changes: 16 additions & 1 deletion Libraries/Components/WebView/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ class WebView extends React.Component {
* @platform android
*/
allowUniversalAccessFromFileURLs: PropTypes.bool,

/**
* Override the native component used to render the WebView. Enables a custom native

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-trailing-spaces: Trailing spaces not allowed.

* WebView which uses the same JavaScript as the original WebView.
*/
nativeComponent: PropTypes.any,

/**
* Set props directly on the native component WebView. Enables custom props which the
* original WebView doesn't pass through.
*/
nativeComponentProps: PropTypes.object
};

static defaultProps = {
Expand Down Expand Up @@ -214,8 +226,11 @@ class WebView extends React.Component {
console.warn('WebView: `source.body` is not supported when using GET.');
}

let NativeWebView = this.props.nativeComponent || RCTWebView;

var webView =
<RCTWebView
<NativeWebView
{...this.props.nativeComponentProps}
ref={RCT_WEBVIEW_REF}
key="webViewKey"
style={webViewStyles}
Expand Down
17 changes: 16 additions & 1 deletion Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ class WebView extends React.Component {
* to tap them before they start playing. The default value is `true`.
*/
mediaPlaybackRequiresUserAction: PropTypes.bool,

/**
* Override the native component used to render the WebView. Enables a custom native

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-trailing-spaces: Trailing spaces not allowed.

* WebView which uses the same JavaScript as the original WebView.
*/
nativeComponent: PropTypes.any,

/**
* Set props directly on the native component WebView. Enables custom props which the
* original WebView doesn't pass through.
*/
nativeComponentProps: PropTypes.object
};

state = {
Expand Down Expand Up @@ -394,8 +406,11 @@ class WebView extends React.Component {

const messagingEnabled = typeof this.props.onMessage === 'function';

let NativeWebView = this.props.nativeComponent || RCTWebView;

var webView =
<RCTWebView
<NativeWebView
{...this.props.nativeComponentProps}
ref={RCT_WEBVIEW_REF}
key="webViewKey"
style={webViewStyles}
Expand Down