Including Local HTML File in Webview Component

I’m trying to build a component that contains a local HTML file inside a react-native webview component. Given the particulars of how expo projects are set up, where should I put the HTML file so that it is packaged with the rest of my application and how should I included it in the webview component? Is including the HTML file even possible using expo?

1 Like

You should be able to just require the .html file and then put the content into https://facebook.github.io/react-native/docs/webview.html#source.

I’ve tried including a html file inside a WebView using the following syntax:

render() {
    return (
            <WebView
              source={{ html: require("../web/payment.html") }}
              startInLoadingState
              scalesPageToFit
              javaScriptEnabled
              style={{ flex: 1 }}
            />
    );
  }

However, I’m getting the following error
"ReferenceError: React is not defined"

indicating that it is looking for React in the HTML file. At least I do have confirmation that the HTML file is being loaded.

Any idea why I’m getting the above reference error?

for android, how do we target to file:///android_asset??