Skip to content

Instantly share code, notes, and snippets.

@giioohbernini
Last active July 28, 2020 17:00
Show Gist options
  • Save giioohbernini/cf79a525b73f83d960a8c64ea87a680c to your computer and use it in GitHub Desktop.
Save giioohbernini/cf79a525b73f83d960a8c64ea87a680c to your computer and use it in GitHub Desktop.
Web to native #5
const postMessage = data => {
/* Esse trecho verifica se o método existe.
Quando estivermos rodando no browser ele não irá existir. */
const hasRNPostMessage = window && window.ReactNativeWebView && window.ReactNativeWebView.postMessage
if (hasRNPostMessage) {
const dataStringify = JSON.stringify(data)
window.ReactNativeWebView.postMessage(dataStringify)
}
}
export default postMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment