-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
65 lines (59 loc) · 1.82 KB
/
index.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var React = require('react-native');
var { requireNativeComponent,PropTypes,NativeModules,View } = React;
var UIManager = NativeModules.UIManager;
var WEBVIEW_REF = 'webview';
var WebView = React.createClass({
propTypes: {
...View.propTypes,
automaticallyAdjustContentInsets: PropTypes.bool,
contentInset: PropTypes.object,
html: PropTypes.string,
injectedJavaScript: PropTypes.string,
onNavigationStateChange: PropTypes.func,
renderError: PropTypes.func,
renderLoading: PropTypes.func,
startInLoadingState: PropTypes.bool,
url: PropTypes.string,
javaScriptEnabledAndroid: PropTypes.bool,
},
_onNavigationStateChange: function(event){
if(this.props.onNavigationStateChange){
this.props.onNavigationStateChange(event.nativeEvent);
}
},
_getWebViewHandle: function(){
return React.findNodeHandle(this.refs[WEBVIEW_REF]);
},
goBack: function(){
UIManager.dispatchViewManagerCommand(
_getWebViewHandle,
UIManager.RCTWebView.Commands.goBack,
null,
);
},
goForward: function(){
UIManager.dispatchViewManagerCommand(
_getWebViewHandle,
UIManager.RCTWebView.Commands.goForward,
null,
);
},
reload: function(){
UIManager.dispatchViewManagerCommand(
_getWebViewHandle,
UIManager.RCTWebView.Commands.reload,
null,
);
},
render(){
return(
<NativeWebView
ref={WEBVIEW_REF}
{...this.props}
onNavigationStateChange={this._onNavigationStateChange}
/>
);
}
});
var NativeWebView = requireNativeComponent('RCTWebView',WebView);
module.exports = WebView;