Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

How to view console.log() of webpage running inside React Native WebView?

$
0
0

In my React Native code, I'm try to call my webpage inside WebView component. In that webpage I'm passing some data using window.postMessage() method from injectedJavascript attribute of React Native WebView. Based upon the data that I've passed to my web page, I'm displaying some console.log() on that page. So, my requirement is to capture those console logs from my webpage inside WebView component and display it in my React Native Code.

Below is my WebView Code:

<WebView  source={{      uri: 'https://www.example.com/',  }}  javaScriptEnabled={true}  injectedJavaScript={`window.postMessage({...}, '*')`}  onMessage={(event) => {      const { data } = event.nativeEvent;      console.log('MESSAGE >>>>'+ JSON.stringify(data));  }}/>

In short, whatever is print in the console of my webpage, I want to print that in my React Native's console, so that I can able to debug my webpage from WebView component by passing the data using window.postMessage().


Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>