diff --git a/releases/next/docs/webview.html b/releases/next/docs/webview.html index f729c2be84a..ebce63ac8d6 100644 --- a/releases/next/docs/webview.html +++ b/releases/next/docs/webview.html @@ -16,7 +16,11 @@ placed behind a navigation bar, tab bar, or toolbar. The default value is true.

contentInset {top: number, left: number, bottom: number, right: number} #

The amount by which the web view content is inset from the edges of the scroll view. Defaults to {top: 0, left: 0, bottom: 0, right: 0}.

html string #

Deprecated

Use the source prop instead.

injectedJavaScript string #

Set this to provide JavaScript that will be injected into the web page when the view loads.

mediaPlaybackRequiresUserAction bool #

Boolean that determines whether HTML5 audio and video requires the user -to tap them before they start playing. The default value is true.

onError function #

Function that is invoked when the WebView load fails.

onLoad function #

Function that is invoked when the WebView has finished loading.

onLoadEnd function #

Function that is invoked when the WebView load succeeds or fails.

onLoadStart function #

Function that is invoked when the WebView starts loading.

onNavigationStateChange function #

Function that is invoked when the WebView loading starts or ends.

renderError function #

Function that returns a view to show if there's an error.

renderLoading function #

Function that returns a loading indicator.

scalesPageToFit bool #

Boolean that controls whether the web content is scaled to fit +to tap them before they start playing. The default value is true.

onError function #

Function that is invoked when the WebView load fails.

onLoad function #

Function that is invoked when the WebView has finished loading.

onLoadEnd function #

Function that is invoked when the WebView load succeeds or fails.

onLoadStart function #

Function that is invoked when the WebView starts loading.

onMessage function #

A function that is invoked when the webview calls window.postMessage. +Setting this property will inject a postMessage global into your +webview, but will still call pre-existing values of postMessage.

window.postMessage accepts one argument, data, which will be +available on the event object, event.nativeEvent.data. data +must be a string.

onNavigationStateChange function #

Function that is invoked when the WebView loading starts or ends.

renderError function #

Function that returns a view to show if there's an error.

renderLoading function #

Function that returns a loading indicator.

scalesPageToFit bool #

Boolean that controls whether the web content is scaled to fit the view and enables the user to change the scale. The default value is true.

source {uri: string, method: string, headers: object, body: string}, {html: string, baseUrl: string}, number #

Loads static html or a uri (with optional headers) in the WebView.

startInLoadingState bool #

Boolean value that forces the WebView to show the loading view on the first load.

style View#style #

The style to apply to the WebView.

url string #

Deprecated

Use the source prop instead.

androiddomStorageEnabled bool #

Boolean value to control whether DOM Storage is enabled. Used only in @@ -230,6 +234,53 @@ class ScaledWebView extends } } +class MessagingTest extends React.Component { + webview = null + + state = { + messagesReceivedFromWebView: 0, + message: '', + } + + onMessage = e => this.setState({ + messagesReceivedFromWebView: this.state.messagesReceivedFromWebView + 1, + message: e.nativeEvent.data, + }) + + postMessage = () => { + if (this.webview) { + this.webview.postMessage('"Hello" from React Native!'); + } + } + + render(): ReactElement<any> { + const {messagesReceivedFromWebView, message} = this.state; + + return ( + <View style={[styles.container, { height: 200 }]}> + <View style={styles.container}> + <Text>Messages received from web view: {messagesReceivedFromWebView}</Text> + <Text>{message || '(No message)'}</Text> + <View style={styles.buttons}> + <Button text="Send Message to Web View" enabled onPress={this.postMessage} /> + </View> + </View> + <View style={styles.container}> + <WebView + ref={webview => { this.webview = webview; }} + style={{ + backgroundColor: BGWASH, + height: 100, + }} + source={require('./messagingtest.html')} + onMessage={this.onMessage} + /> + </View> + </View> + ); + } +} + var styles = StyleSheet.create({ container: { flex: 1, @@ -404,6 +455,10 @@ exports.examples /> ); } + }, + { + title: 'Mesaging Test', + render(): ReactElement<any> { return <MessagingTest />; } } ];

Run this example

← PrevNext →