App.js
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React, { Component } from "react";
import { StyleSheet, View, Button } from "react-native";
import CustomWebView from "react-native-webview-android-file-upload";
export default class App extends Component {
inject = () => {
this.webview.injectJavaScript("alert('JavaScript is injected')");
};
reload = () => {
this.webview.reload();
};
render() {
return (
<View style={styles.container}>
<CustomWebView
style={styles.container}
webviewRef={e => (this.webview = e)}
injectedJavaScript={"alert('Custom webview loaded')"}
source={{
uri:
"https://andreipfeiffer.github.io/react-native-webview-android-file-upload/index.html"
}}
/>
<View style={styles.containerHorizontal}>
<Button title="Reload" onPress={this.reload} />
<Button title="Inject JS" onPress={this.inject} />
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
containerHorizontal: {
flexDirection: "row",
justifyContent: "space-around",
paddingVertical: 10,
backgroundColor: "#eee"
}
});