I am working on a project for Math-Tuition(React-native mobile app), and using wiris
for setting up questions and answers. wiris sends those questions in MathML, I am converting MathML(equations, graphs etc) into JSX by using npm package react-native-mathjax
.
My web team has developed same on web in vue.js, wiris also gives input felids variables to write answers, I need to do some middle calculation/re-format on those variables by using some javascript functions, Those functions are written in a external file in javascript and same file web developer(vue.js) using.
I was trying to inject js code in webview but unable to import that js functions file in react-native, Can someone suggest me better. Thanks in advance :) I am sharing code of import js file. Code is even not giviing error if i write wrong path of external js file.
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native'; import { WebView } from 'react-native-webview';
export default class sampleReactApp extends Component {
render() {
let HTML = <html> <head> <script type="text/javascript" src="./quizzes.js"></script> </head> <body> <div id="workbookControl"></div> <div id="tableeditor" style="font-size : 50px;">I am written inside source HTML</div> <div id="msg" onclick="javascript:alert('Hi')" style="font-size : 50px;" >notify alert</div> </body> </html>
;
let jsCode = alert("Js");
;
return (
<View style={{flex: 1}}>
<WebView ref={ref => { this.webview = ref; }}
source={{ html: HTML }}
injectedJavaScript={jsCode}
javaScriptEnabledAndroid={true}
javaScriptEnabled={true}
>
</WebView>
</View>
);
}
}