I\'m trying to load .html
, .js
, .css
files from device\'s local file system into React Native WebView component. I was able to get the
Place this script in any file of ReactNative or your code, recomended to first or top index file. And it will fix problem, tested on RN0.39
import { Platform } from 'react-native';
import { setCustomSourceTransformer } from 'react-native/Libraries/Image/resolveAssetSource';
setCustomSourceTransformer(function (resolver) {
if (Platform.OS === 'android'
&& !resolver.serverUrl
&& !resolver.bundlePath
&& resolver.asset.type === 'html') {
resolver.bundlePath = '/android_asset/';
}
return resolver.defaultAsset();
});