After a lot of research I came out with this solution for make a WebView works with local assets.This solution works in Android and iOS both inside the Expo app (dev and production mode both), but it doesn’t in Testflight.
How can I solve? Most of all, there is a way I can debug the Js code of the WebView?
import {WebView, Platform, View} from 'react-native';
const INDEX_FILE_PATH = './index.html';
const INDEX_FILE_ASSET_URI = Asset.fromModule(require(INDEX_FILE_PATH)).uri;
class WB extends Component {
render() {
return (
<View>
<WebView
source={
Platform.OS === 'ios'
? require(INDEX_FILE_PATH)
: { uri: INDEX_FILE_ASSET_URI }
}
javaScriptEnabled={true}
domStorageEnabled={true}
useWebKit={true}
ref={webview => { this.myWebView = webview; }}
scrollEnabled={false}
mixedContentMode='always'
renderError={(error)=>console.log('error:',error)}
onMessage={this.onWebViewMessage}
/>
</View>
);
}
}