(React Native) Load local HTML file into WebView

I come across this post searching for loading static html.
If your html code is retrieved using, for example, an API, you can render WebView in this way:

<WebView
    originWhitelist={['*']}
    source={{ html: html, baseUrl: '' }}
/>

Notice that originWhitelistis required as explained in the documentation:

Note that static html will require setting of originWhitelist for example to ["*"].


try it:

const PolicyHTML = require('./Policy.html');

<WebView
  source={PolicyHTML}
  style={{flex: 1}}
 />

<View style={{flex: 1}}>
    <WebView
      style={{flex: 1}}
      source={require("./resources/index.html")}
    />
</View>

To make WebView, the parent has to has a dimension or flex:1. We could set the WebView to flex: 1 too so that it fills up the parent.