Search code examples
javascriptwebviewreact-nativexmlhttprequestandroid-assets

React-native WebView: Load html and js from assets folder


I need to load html and js files from assets folder in the WebView. I have tried using :

<WebView source={{uri: "file:///android_asset/index.html"}} />

along with javaScriptEnabled={true}. The html file is loaded but XMLHttpRequest stops working. I guess it's due to the 'file' protocol.

Is there any other way to access the files in assets folder without using file:///? Or in that matter, any other solution to this problem.


Solution

  • Found the way. Used react-native-static-server to create a server and load html file.