Created
April 9, 2017 21:58
-
-
Save gs-akhan/3e6e1489ef8e17db87c7a9ab3cf3fe90 to your computer and use it in GitHub Desktop.
Sending Data from WebView To React Native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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