File tree Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,29 @@ var Sample2 = React.createClass({
44
44
} ,
45
45
render : function ( ) {
46
46
return (
47
+ < View style = { styles . container } >
47
48
< WebViewBridge
48
49
ref = "webviewbridge"
49
50
onBridgeMessage = { this . onBridgeMessage }
50
51
javaScriptEnabled = { true }
51
52
injectedJavaScript = { injectScript }
52
53
source = { { uri : "https://google.com" } } />
54
+ < WebViewBridge
55
+ ref = "webviewbridge"
56
+ onBridgeMessage = { this . onBridgeMessage }
57
+ javaScriptEnabled = { true }
58
+ injectedJavaScript = { injectScript }
59
+ source = { require ( './test.html' ) } />
60
+ </ View >
53
61
) ;
54
62
}
55
63
} ) ;
56
64
57
65
module . exports = Sample2 ;
66
+
67
+ const styles = StyleSheet . create ( {
68
+ container : {
69
+ flex : 1
70
+ }
71
+ } ) ;
72
+
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < title > </ title >
5
+ </ head >
6
+ < body >
7
+ Hello test html
8
+ </ body >
9
+ </ html >
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ var React = require('react-native');
17
17
var invariant = require ( 'invariant' ) ;
18
18
var keyMirror = require ( 'keymirror' ) ;
19
19
var merge = require ( 'merge' ) ;
20
+ var resolveAssetSource = require ( 'react-native/Libraries/Image/resolveAssetSource.js' ) ;
21
+
20
22
21
23
var {
22
24
ReactNativeViewAttributes,
@@ -110,11 +112,20 @@ var WebViewBridge = React.createClass({
110
112
domStorageEnabled = this . props . domStorageEnabledAndroid ;
111
113
}
112
114
115
+ let props = { ...this . props } ;
116
+ var source = props . source || { } ;
117
+ if ( this . props . html ) {
118
+ source . html = this . props . html ;
119
+ } else if ( this . props . url ) {
120
+ source . uri = this . props . url ;
121
+ }
122
+ props . source = resolveAssetSource ( source ) ;
123
+
113
124
var webView =
114
125
< RCTWebViewBridge
115
126
ref = { RCT_WEBVIEWBRIDGE_REF }
116
127
key = "webViewKey"
117
- { ...this . props }
128
+ { ...props }
118
129
style = { webViewStyles }
119
130
onLoadingStart = { this . onLoadingStart }
120
131
onLoadingFinish = { this . onLoadingFinish }
Original file line number Diff line number Diff line change 17
17
var React = require ( 'react-native' ) ;
18
18
var invariant = require ( 'invariant' ) ;
19
19
var keyMirror = require ( 'keymirror' ) ;
20
+ var resolveAssetSource = require ( 'react-native/Libraries/Image/resolveAssetSource.js' ) ;
20
21
21
22
var {
22
23
ActivityIndicatorIOS,
@@ -174,10 +175,19 @@ var WebViewBridge = React.createClass({
174
175
}
175
176
} ;
176
177
177
- const props = { ...this . props } ;
178
+ let props = { ...this . props } ;
178
179
delete props . onBridgeMessage ;
179
180
delete props . onShouldStartLoadWithRequest ;
180
181
182
+ var source = props . source || { } ;
183
+ if ( this . props . html ) {
184
+ source . html = this . props . html ;
185
+ } else if ( this . props . url ) {
186
+ source . uri = this . props . url ;
187
+ }
188
+ props . source = resolveAssetSource ( source ) ;
189
+
190
+
181
191
var webView =
182
192
< RCTWebViewBridge
183
193
ref = { RCT_WEBVIEWBRIDGE_REF }
You can’t perform that action at this time.
0 commit comments