I need to use/import a JavaScript plugin in React-native. Plugin file contains functions, written in javascript and not in es6 format. I need to use those in react-native either by Webview or can be other way.
I already tried WebView, But html code is not even loading JS plugin file (<script type="text/javascript" src="./testjs.js">
)
Because when I give it a wrong path It should give me some file missing error, While Simple alert on same place is working.
here below is render on RN screen :-
render () {
var HTML = `<html> <head> <script type="text/javascript" src="./testjs.js"></script> </head> <body> <div id="workbookControl"></div> <div id="tableeditor" style="font-size : 50px;">I am written inside source HTML</div> </body> </html>`
var jsCode = ` true;`
return (
<WebView
originWhitelist={['*']}
source={{ html: HTML }}
injectedJavaScript={jsCode}
onMessage={() => {}}
javaScriptEnabledAndroid={true}
javaScriptEnabled={true}
/>
)
}
And here is code of testjs.js
(function hello(ddd) { alert("heiii"); return "Hello"; })(); true;
I want to call this hello() from testjs.js, How can I do that ?