간단한 코드는 inline으로
import React, { Component } from 'react'; import { WebView } from 'react-native-webview'; class MyInlineWeb extends Component { render() { return ( <WebView originWhitelist={['*']} source={{ html: `<h1>This is a static HTML source!</h1>` }} /> ); } }
작성된 html 파일 연동하기
- 공식 문서 : Loading local HTML files
확장자를
.html
로 하고, 로컬의 html
파일을 불러와서 보여주는 방식은 현재 이슈가 있다.대신 목적이 html 코드를 별도 코드에서 관리하고 싶은 거라고 한다면 html 텍스트를 반환해주는 로직을 담은 js 파일로 분리해서 사용할 수는 있다.
