Skip to content

Instantly share code, notes, and snippets.

@gs-akhan
Created April 9, 2017 21:58
Show Gist options
  • Save gs-akhan/3e6e1489ef8e17db87c7a9ab3cf3fe90 to your computer and use it in GitHub Desktop.
Save gs-akhan/3e6e1489ef8e17db87c7a9ab3cf3fe90 to your computer and use it in GitHub Desktop.
Sending Data from WebView To React Native
//This sends data from WebView to React Native
...
<script>
window.postMessage("Sending data from WebView");
</script>
...
//In order to get data the was sent from WebView use onMessage prop on <WebView>
...
<WebView
ref="webview"
onMessage={this.onMessage}
/>
onMessage(data) {
//Prints out data that was passed.
console.log(data);
}
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment