Last active
July 28, 2020 17:00
-
-
Save giioohbernini/cf79a525b73f83d960a8c64ea87a680c to your computer and use it in GitHub Desktop.
Web to native #5
This file contains 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
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