React-native: [WebViewExample] Bundled HTML does not work

Created on 18 Feb 2016  路  18Comments  路  Source: facebook/react-native

I cannot render bundled HTML file in WebView. I suppose it is a bug in React Native because it does not work also in your WebViewExample and UIExplorer.

Error in Android emulator:

  • E/ReactNativeJS: Requiring unknown module "./helloworld.html". If you are sure the module is there, try restarting the packager.
  • Restart of packager did not help.
  • React Native version: 0.19

Error in your online UIExplorer:

  • Error loading page. Domain: NSURLErrorDomain. Error Code: -1100. Description: The requested URL was not found on this server.
  • See screenshot.

uiexplorer-webview-bundledhtml-error

Locked

Most helpful comment

Not working on RN 0.37 as well.

All 18 comments

It's fixed in React Native v.0.20, but there is still the same error in UIExplorer. Maybe it was not upgraded to latest version yet. Thank you guys!

+1 have encountered the same issues

I have the same error and behavior , can't present local html in webView in both ios and Android.
here's a sample RN app to demonstrate the behavior.

sample app

any idea? I'm on 0.23.1 and now testing on 0.24 and it also don't wokr.

+1 It doesn't work on the latest 0.25.1

@comiclee one solution is to load the html with require , I still haven't upgraded to 0.25 but it works for 0.23

@rotemsloo, require html files can work in develope mode, but fails in release apk file

+1. I'm seeing this on latest version. Debug build is fine, but release shows blank page.

cc: @dmmiller

Looking at release build now. Thanks for the heads up.

As far as I can tell this got fixed. I'm going to close this issue but if people see it recur with recent builds of React Native please feel free to open a new issue.

Its still not working, I mean its not fixed.

RN 0.36 on Android. Assets need to be manually placed as suggested above.

Not working on RN 0.37 as well.

Not working on RN 0.39.2 as well.

Not working on RN 0.40 as well.

Not working on RN 0.41 as well.

on RN 0.40, require('./file.html') is failing for me in Build release variant. as others have mentioned above.
As workaround, I was able to put the file in android assets dir, and { uri: file:///android_asset/file.html } it in from there. Unfortunately for my situation, the html file loads remote third-party libs which internally reference protocol-agnostic resources: e.g., //domain.com/file.json. So those all got turned into file://domain.com/file.json links and of course failed.
I monkey patched XMLHttpRequest to change //... to https://... which solved that problem, but none of the images those libs attempt to load, will load. all broken. And I've been unable to find a way to determine what the requests look like for those images, to see why they break/fail-to-load.

As @lacker was saying we should open a new issue, has anyone opened a new issue for this? Or should we continue in this thread? For me, it seems we should continue here only and re-open this one.

It looks like this is being tracked in this issue now: https://github.com/facebook/react-native/issues/7924

Was this page helpful?
0 / 5 - 0 ratings