Skip to content

Instantly share code, notes, and snippets.

@winadiw
Forked from gs-akhan/index.js
Created August 9, 2018 07:22
Show Gist options
  • Select an option

  • Save winadiw/c80fac5ddd7d7090a162abb12c273bae to your computer and use it in GitHub Desktop.

Select an option

Save winadiw/c80fac5ddd7d7090a162abb12c273bae 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