Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to give data from react native to webview

// Web App
<button onClick={() => {
  if(window.ReactNativeWebView) { // ensure window.ReactNativeWebView is there, otherwise, web app might crash if is not there
    window.ReactNativeWebView.postMessage('Wayne is coming again')
  }
}}>
</button>

// Native App
<WebView
  onMessage={(event) => {
    console.log(event.nativeEvent.data) // Client received data
  }}
  source={{ uri: 'https://your.domain.com' }}
/>
Comment

how to give data from react native to webview

// Native
this.webviewRef.postMessage('Wayne is coming!!!')

// Web
window.addEventListener("message", message => {
  console.log(message.data) // Wayne is coming!!!
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript check type of variable var 
Javascript :: sort array of objects based on another array javascript 
Javascript :: datatable buttons bootstrap 4 
Javascript :: mongoose encrypt database using mongoose encrypt package 
Javascript :: create array in javascript contains 10 elements 
Javascript :: How create a function that return element in js 
Javascript :: loop through elements by name js 
Javascript :: javascript prevent right click 
Javascript :: Nextjs mongodb connection setup 
Javascript :: number of edges between set of nodes networkx 
Javascript :: formdata is empty after append in angular 
Javascript :: vue slice words 
Javascript :: axios httsagent 
Javascript :: Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.6/$injector/modulerr?p0=myApp 
Javascript :: escape double quotes in json 
Javascript :: what is ... in javascript 
Javascript :: body onload jQuery | jQuery equivalent of body onLoad 
Javascript :: google scripts string split 
Javascript :: router.push next js 
Javascript :: objeto con método javascript 
Javascript :: remove the last character from a string in JavaScript, 
Javascript :: vue mixin example 
Javascript :: Delete a user in ExpressJS 
Javascript :: what is angularjs 
Javascript :: graphql yoga access http headers 
Javascript :: update array usestate 
Javascript :: yarn create react app in current directory 
Javascript :: javascript match 
Javascript :: [Object] node js output 
Javascript :: add new array at the back of react state 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =