Skip to content

Commit afeecc3

Browse files
committed
docs: enhance documentation for the iframe-plugin
1 parent 20e284d commit afeecc3

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

packages/iframe-plugin/README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,33 @@
2828
🌐 A WebView-based plugin to render iframes in react-native-render-html.
2929
</p>
3030

31-
<p align="center">
32-
<img
33-
src="expo-example"
34-
/>
35-
</p>
36-
<div align="center">
37-
<a href="https://expo.io/@jsamr/native-html-iframe-plugin-example"
38-
>Try it on Expo!</a
39-
>
40-
</div>
41-
<div align="center">
42-
<img
43-
src="https://github.com/native-html/iframe-plugin/raw/master/images/android.gif"
44-
width="300"
45-
/>
46-
</div>
4731
<hr/>
4832

33+
**Install**:
34+
35+
> :warning: With expo, use `expo install` instead to grab a compatible
36+
> `react-native-webview` version.
37+
4938
```sh
50-
npm add --save @native-html/iframe-plugin
39+
npm add --save @native-html/iframe-plugin react-native-webview
5140
```
5241

5342
```sh
54-
yarn add @native-html/iframe-plugin
43+
yarn add @native-html/iframe-plugin react-native-webview
5544
```
5645

5746
**Features**:
5847

48+
- Supports `onLinkPress`;
49+
- Supports `defaultWebViewProps`;
50+
- Compliance with [RFC001](https://github.com/archriss/react-native-render-html/blob/master/rfc/001-A-deterministic-approach-to-embedded-content-scaling.adoc#L13): scales to available width;
51+
- A single renderer function exported as default, super easy to plug-in!
52+
- Compatible with `react-native-web` via [`@formidable-webview/web`](https://github.com/formidable-webview/ubiquitous/tree/master/packages/web#readme)
53+
5954
**Known Limitations**:
6055

56+
- With `react-native-web`, `onLinkPress` will not work for external domains.
57+
6158
## Compat Table
6259

6360
| react-native-render-html | @native-html/iframe-plugin | Documentation |
@@ -67,8 +64,23 @@ yarn add @native-html/iframe-plugin
6764

6865
## Minimal working example
6966

70-
## API Reference
67+
> :warning: This plugin requires `react-native-render-html` version 5 or greater
68+
69+
```jsx
70+
import iframe from '@native-html/iframe-plugin';
71+
import HTML from 'react-native-render-html';
72+
import WebView from 'react-native-webview';
73+
74+
const renderers = {
75+
iframe
76+
}
7177

72-
**The complete API reference is available here: [docs/iframe-plugin.md](docs/iframe-plugin.md).**
78+
// ...
7379

74-
## Troubleshooting
80+
<HTML renderers={renderers}
81+
WebView={WebView}
82+
source={{ html: '<iframe ...></iframe>' }}
83+
defaultWebViewProps={{ /* Any prop you want to pass to WebView */ }}
84+
/>
85+
86+
```

packages/iframe-plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"metro-react-native-babel-transformer": "^0.64.0",
5353
"react": "16.14.0",
5454
"react-native": "^0.63.2",
55-
"react-native-render-html": "5.0.0-alpha.5",
55+
"react-native-render-html": "5.0.0-alpha.6",
5656
"react-native-webview": "^10.9.0",
5757
"react-test-renderer": "16.13.1",
5858
"release-it": "^14.2.2",

packages/iframe-plugin/src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const iframe: RendererFunction<any> = function iframe(
3030
WebView,
3131
contentWidth,
3232
onLinkPress,
33-
computeEmbeddedMaxWidth
33+
computeEmbeddedMaxWidth,
34+
defaultWebViewProps
3435
} = passProps;
3536
const resolvedContentWidth =
3637
typeof contentWidth === 'number'
@@ -78,6 +79,7 @@ const iframe: RendererFunction<any> = function iframe(
7879
WebView={WebView}
7980
htmlAttribs={htmlAttribs}
8081
onLinkPress={onLinkPress}
82+
webViewProps={defaultWebViewProps}
8183
/>
8284
) : null;
8385
};

0 commit comments

Comments
 (0)