๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ–ฅ๏ธํ”„๋ก ํŠธ์—”๋“œ/React Native

๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ - WebView ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์กฐ์ž‘ & WebView์™€ ์•ฑ ๋ฉ”์‹œ์ง€ ์ „๋‹ฌ

by Janger 2022. 10. 21.
728x90
๋ฐ˜์‘ํ˜•
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

 

https://medium.com/capriza-engineering/communicating-between-react-native-and-the-webview-ac14b8b8b91a

 

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

 

728x90
๋ฐ˜์‘ํ˜•