chore(docs): Create example for injectedJavaScript (#571)
This commit is contained in:
parent
d72c2ae144
commit
a0daff92c0
|
@ -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`
|
||||
|
|
Loading…
Reference in New Issue