Closed eladcandroid closed 8 years ago
This is what worked for me. Please add that to the docs:
import React, { Component } from 'react';
import {AppRegistry,StyleSheet} from 'react-native';
import WebViewAndroid from 'react-native-webview-android';
const SITE_URL = "https://www.google.com";
export default class WebViewAndroidExample extends Component {
constructor(props) {
super(props);
this.state = {
url: SITE_URL,
status: 'No Page Loaded',
backButtonEnabled: false,
forwardButtonEnabled: false,
loading: true,
};
};
goBack() {
this.refs.webViewAndroidSample.goBack(); // you can use this callbacks to control webview
};
goForward() {
this.refs.webViewAndroidSample.goForward();
};
reload() {
this.refs.webViewAndroidSample.reload();
};
onNavigationStateChange(event) {
console.log(event);
this.state = {
backButtonEnabled: event.canGoBack,
forwardButtonEnabled: event.canGoForward,
url: event.url,
status: event.title,
loading: event.loading
};
};
render() {
return (
<WebViewAndroid
ref="webViewAndroidSample"
javaScriptEnabled={true}
geolocationEnabled={false}
builtInZoomControls={false}
onNavigationStateChange={this.onNavigationStateChange}
url={SITE_URL}
style={styles.containerWebView} />
);
}
}
const styles = StyleSheet.create({
containerWebView: {
flex: 1,
}
});
AppRegistry.registerComponent('WebViewAndroidExample', () => WebViewAndroidExample);
OK, it's something like this: