From ee49a4763b2e88cf72d440f03e51e9551caaae7e Mon Sep 17 00:00:00 2001 From: Caleb Clarke Date: Sun, 15 Jul 2018 12:19:53 -0700 Subject: [PATCH] react-native - Added nativeConfig to WebViewProps (#27211) * Added nativeConfig to WebViewProps * Added test * Object -> object * Added remaining nativeConfig properties to test --- types/react-native/index.d.ts | 59 ++++++++++++++++++++++--------- types/react-native/test/index.tsx | 1 + 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 3b44a980b3..28bb0a4058 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -2183,43 +2183,62 @@ export interface WebViewPropsIOS { export interface WebViewUriSource { /* - * The URI to load in the WebView. Can be a local or remote file. - */ + * The URI to load in the WebView. Can be a local or remote file. + */ uri?: string; /* - * The HTTP Method to use. Defaults to GET if not specified. - * NOTE: On Android, only GET and POST are supported. - */ + * The HTTP Method to use. Defaults to GET if not specified. + * NOTE: On Android, only GET and POST are supported. + */ method?: string; /* - * Additional HTTP headers to send with the request. - * NOTE: On Android, this can only be used with GET requests. - */ + * Additional HTTP headers to send with the request. + * NOTE: On Android, this can only be used with GET requests. + */ headers?: any; /* - * The HTTP body to send with the request. This must be a valid - * UTF-8 string, and will be sent exactly as specified, with no - * additional encoding (e.g. URL-escaping or base64) applied. - * NOTE: On Android, this can only be used with POST requests. - */ + * The HTTP body to send with the request. This must be a valid + * UTF-8 string, and will be sent exactly as specified, with no + * additional encoding (e.g. URL-escaping or base64) applied. + * NOTE: On Android, this can only be used with POST requests. + */ body?: string; } export interface WebViewHtmlSource { /* - * A static HTML page to display in the WebView. - */ + * A static HTML page to display in the WebView. + */ html: string; /* - * The base URL to be used for any relative links in the HTML. - */ + * The base URL to be used for any relative links in the HTML. + */ baseUrl?: string; } +export interface WebViewNativeConfig { + /* + * The native component used to render the WebView. + */ + component?: any; + + /* + * Set props directly on the native component WebView. Enables custom props which the + * original WebView doesn't pass through. + */ + props?: object; + + /* + * Set the ViewManager to use for communication with the native side. + * @platform ios + */ + viewManager?: object; +} + /** * @see https://facebook.github.io/react-native/docs/webview.html#props */ @@ -2319,6 +2338,12 @@ export interface WebViewProps extends ViewProps, WebViewPropsAndroid, WebViewPro * The default whitelisted origins are "http://" and "https://". */ originWhitelist?: string[]; + + /** + * Override the native component used to render the WebView. Enables a custom native + * WebView which uses the same JavaScript as the original WebView. + */ + nativeConfig?: WebViewNativeConfig; } export class WebView extends React.Component { diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 705b4707cf..aa22d21fd7 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -615,6 +615,7 @@ class WebViewTest extends React.Component { ); }