File tree Expand file tree Collapse file tree 6 files changed +33
-7
lines changed
android/src/main/java/com/github/alinz/reactnativewebviewbridge Expand file tree Collapse file tree 6 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ private void injectBridgeScript(WebView root) {
72
72
if (!initializedBridge ) {
73
73
root .addJavascriptInterface (new JavascriptBridge ((ReactContext )root .getContext ()), "WebViewBridgeAndroid" );
74
74
initializedBridge = true ;
75
+ root .reload ();
75
76
}
76
77
77
78
//this code needs to be executed everytime a url changes.
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 = "webviewbridge2"
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 1
1
{
2
2
"name" : " react-native-webview-bridge" ,
3
- "version" : " 0.20.1 " ,
3
+ "version" : " 0.20.2 " ,
4
4
"description" : " React Native WebView Javascript Bridge" ,
5
5
"main" : " webview-bridge" ,
6
6
"directories" : {
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ var React = require('react-native');
17
17
var invariant = require ( 'invariant' ) ;
18
18
var keyMirror = require ( 'keymirror' ) ;
19
19
var merge = require ( 'merge' ) ;
20
- import resolveAssetSource from ' resolveAssetSource';
20
+ var resolveAssetSource = require ( 'react-native/Libraries/Image/ resolveAssetSource') ;
21
21
22
22
var {
23
23
ReactNativeViewAttributes,
@@ -112,14 +112,14 @@ var WebViewBridge = React.createClass({
112
112
}
113
113
114
114
let props = { ...this . props } ;
115
- const source = resolveAssetSource ( props . source ) ;
116
- delete props . source ;
117
-
115
+ props . source = resolveAssetSource ( props . source ) ;
116
+
118
117
var webView =
119
118
< RCTWebViewBridge
120
119
ref = { RCT_WEBVIEWBRIDGE_REF }
121
120
key = "webViewKey"
122
121
{ ...props }
122
+ source = { source }
123
123
style = { webViewStyles }
124
124
onLoadingStart = { this . onLoadingStart }
125
125
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
- import resolveAssetSource from ' resolveAssetSource';
20
+ var resolveAssetSource = require ( 'react-native/Libraries/Image/ resolveAssetSource') ;
21
21
22
22
var {
23
23
ActivityIndicatorIOS,
@@ -176,11 +176,12 @@ var WebViewBridge = React.createClass({
176
176
} ;
177
177
178
178
let props = { ...this . props } ;
179
- const source = resolveAssetSource ( props . source ) ;
180
179
delete props . onBridgeMessage ;
181
180
delete props . onShouldStartLoadWithRequest ;
182
181
delete props . source ;
183
182
183
+ props . source = resolveAssetSource ( props . source ) ;
184
+
184
185
var webView =
185
186
< RCTWebViewBridge
186
187
ref = { RCT_WEBVIEWBRIDGE_REF }
You can’t perform that action at this time.
0 commit comments