chore(docs): Create example for injectedJavaScript (#571)

This commit is contained in:
Malcolm Scruggs 2019-05-16 15:24:18 -07:00 committed by Thibault Malbranche
parent d72c2ae144
commit a0daff92c0
1 changed files with 16 additions and 0 deletions

View File

@ -115,6 +115,22 @@ Set this to provide JavaScript that will be injected into the web page when the
To learn more, read the [Communicating between JS and Native](Guide.md#communicating-between-js-and-native) guide.
Example:
Post message a JSON object of `window.location` to be handled by [`onMessage`](Reference.md#onmessage)
```jsx
const INJECTED_JAVASCRIPT = `(function() {
window.ReactNativeWebView.postMessage(JSON.stringify(window.location));
})();`;
<WebView
source={{ uri: 'https://facebook.github.io/react-native' }}
injectedJavaScript={INJECTED_JAVASCRIPT}
onMessage={this.onMessage}
/>
```
---
### `mediaPlaybackRequiresUserAction`