Skip to content

Commit b2cc20d

Browse files
author
Rodrigo Bermudez Schettino
committed
Add example with inline HTML to WebView
Show required props to render inline HTML in WebView.
1 parent a75b008 commit b2cc20d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/webview.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ class MyWeb extends Component {
2121
}
2222
```
2323

24+
Minimal example with inline HTML:
25+
26+
```
27+
import React, { Component } from 'react';
28+
import { WebView } from 'react-native';
29+
30+
class MyInlineWeb extends Component {
31+
render() {
32+
return (
33+
<WebView
34+
originWhitelist={['*']}
35+
source={{ html: '<h1>Hello world</h1>' }}
36+
/>
37+
);
38+
}
39+
}
40+
```
41+
2442
You can use this component to navigate back and forth in the web view's history and configure various properties for the web content.
2543

2644
> **Security Warning:** Currently, `onMessage` and `postMessage` do not allow specifying an origin. This can lead to cross-site scripting attacks if an unexpected document is loaded within a `WebView` instance. Please refer to the MDN documentation for [`Window.postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) for more details on the security implications of this.

0 commit comments

Comments
 (0)