Skip to content

Commit

Permalink
Add example with inline HTML to WebView (#497)
Browse files Browse the repository at this point in the history
* Formatting from Docusaurus

Running yarn start changed the format of en.json automatically.

* Add example with inline HTML to WebView

Show required props to render inline HTML in WebView.
  • Loading branch information
rodrigobdz authored and hramos committed Aug 8, 2018
1 parent df040b5 commit b717f68
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/webview.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class MyWeb extends Component {
}
```

Minimal example with inline HTML:

```
import React, { Component } from 'react';
import { WebView } from 'react-native';
class MyInlineWeb extends Component {
render() {
return (
<WebView
originWhitelist={['*']}
source={{ html: '<h1>Hello world</h1>' }}
/>
);
}
}
```

You can use this component to navigate back and forth in the web view's history and configure various properties for the web content.

> **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.
Expand Down

0 comments on commit b717f68

Please sign in to comment.