From 512a43b9c0deaa507e3a93266f517ace71a0f415 Mon Sep 17 00:00:00 2001 From: "Pablo E. L. Targino" Date: Tue, 23 Jul 2024 16:54:09 -0300 Subject: [PATCH 1/3] Add inject method --- src/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/index.js b/src/index.js index 1c5d65c..4239879 100644 --- a/src/index.js +++ b/src/index.js @@ -106,6 +106,10 @@ export class WebView extends Component { } }; + injectJavaScript = (js) => { + this.frameRef.contentWindow.Function(js)(); + }; + render() { if (this.props.newWindow) { return ( From 1e0207385cb15a0754f29fcf2f37bd6172feac07 Mon Sep 17 00:00:00 2001 From: "Pablo E. L. Targino" Date: Tue, 23 Jul 2024 16:55:35 -0300 Subject: [PATCH 2/3] Add a component to test inject to the docs --- docs/stories/components/InjectableWebView.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/stories/components/InjectableWebView.jsx diff --git a/docs/stories/components/InjectableWebView.jsx b/docs/stories/components/InjectableWebView.jsx new file mode 100644 index 0000000..7307159 --- /dev/null +++ b/docs/stories/components/InjectableWebView.jsx @@ -0,0 +1,19 @@ +import React, { Component } from 'react'; +import { Button, View } from 'react-native-web'; +import WebView from 'react-native-webview'; + +export default class InjectableWebView extends Component { + constructor(props) { + super(props); + this.ref = React.createRef(); + } + + render() { + return ( + + +