File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 WebView ,
1919 Platform ,
2020} from 'react-native' ;
21+ import PropTypes from "prop-types" ;
2122
2223const injectedScript = function ( ) {
2324 function waitForBridge ( ) {
@@ -38,9 +39,14 @@ export default class MyWebView extends Component {
3839 webViewHeight : Number
3940 } ;
4041
42+ static propTypes = {
43+ onMessage : PropTypes . func
44+ } ;
45+
4146 static defaultProps = {
42- autoHeight : true ,
43- }
47+ autoHeight : true ,
48+ onMessage : ( ) => { }
49+ } ;
4450
4551 constructor ( props : Object ) {
4652 super ( props ) ;
@@ -52,9 +58,11 @@ export default class MyWebView extends Component {
5258 }
5359
5460 _onMessage ( e ) {
61+ const { onMessage } = this . props ;
5562 this . setState ( {
5663 webViewHeight : parseInt ( e . nativeEvent . data )
5764 } ) ;
65+ onMessage ( e ) ;
5866 }
5967
6068 stopLoading ( ) {
@@ -76,11 +84,11 @@ export default class MyWebView extends Component {
7684 ref = { ( ref ) => { this . webview = ref ; } }
7785 injectedJavaScript = { Platform . OS === 'ios' ? iosScript : androidScript }
7886 scrollEnabled = { this . props . scrollEnabled || false }
79- onMessage = { this . _onMessage }
8087 javaScriptEnabled = { true }
8188 automaticallyAdjustContentInsets = { true }
8289 { ...this . props }
83- style = { [ { width : _w } , this . props . style , { height : _h } ] }
90+ onMessage = { this . _onMessage }
91+ style = { [ { width : _w } , this . props . style , { height : _h } ] }
8492 />
8593 )
8694 }
You can’t perform that action at this time.
0 commit comments