import * as React from 'react';
import { WebView } from 'react-native-webview';
import { StyleSheet } from 'react-native';
import Constants from 'expo-constants';
export default function App() {
return (
<WebView
style={styles.container}
source={{ uri: 'https://expo.dev' }}
javaScriptEnabled={true}
injectedJavaScript={"document.body.innerHTML = \"abc\";window.ReactNativeWebView.postMessage(document.body.innerHTML)"}
onMessage={(event)=>{console.log(event.nativeEvent.data)}}
/>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: Constants.statusBarHeight,
},
});
์ฐธ๊ณ :
https://docs.expo.dev/versions/latest/sdk/webview/
WebView - Expo Documentation
Expo is an open-source platform for making universal native apps for Android, iOS, and the web with JavaScript and React.
docs.expo.dev
Communicating between React Native and the WebView
Our current WorkSimple app in production is a Cordova hybrid app which means that our UI is web based. We are putting in a lot of effort…
medium.com
https://stackoverflow.com/questions/68451589/react-native-webview-onmessage-is-not-triggered
React Native WebView onMessage() is not triggered
I have a static site hosted on S3 with CloudFront distro on top of it. <WebView ref={webViewRef} scrollEnabled={false} source={{ uri: Config.REMOTE_URL }} // CloudFront URL
stackoverflow.com
'๐ฅ๏ธํ๋ก ํธ์๋ > React Native' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ฆฌ์กํธ ๋ค์ดํฐ๋ธ - MapView Marker ์ฌ์ฉ ์์ (1) | 2022.10.14 |
---|---|
๋ฆฌ์กํธ ๋ค์ดํฐ๋ธ - ์ ์ฉํ ์ฌ์ดํธ ๋ชจ์ (0) | 2022.10.10 |
๋ฆฌ์กํธ ๋ค์ดํฐ๋ธ - Expo snack์์ ํจํค์ง ์ถ๊ฐ ๋ฐฉ๋ฒ (0) | 2022.10.10 |
React Native - ์ด๊ธฐ ์ค์น (0) | 2022.04.07 |