Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 871
User4870 Avatar asked Apr 17 '26 10:04

User4870


1 Answers

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

like image 70
User4870 Avatar answered Apr 18 '26 22:04

User4870