Norlihazmey Ghazali
Norlihazmey Ghazali

Reputation: 9060

Webview not showing any content(html) react native

Contents did showing up perfectly inside emulator and debug with real device but does not showing anything when testing out with real device (using released .apk). It just only showed blank container with white color. Or do i missed something?

<WebView
     ref={(wView) => {this.wView = wView}}
     javaScriptEnabled={true}
     // onBridgeMessage={this.onBridgeMessage}
     onMessage={this.onMessage}
     injectedJavaScript="window.postMessage = String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage');"               
     automaticallyAdjustContentInsets={false}
     domStorageEnabled={true}
     startInLoadingState={true}
     source={mainHtml} <-- load with, var mainHtml = require('./MainHtml.html');
     style={{width: 320,height:100,flex: 1}}/>

Environment

Upvotes: 2

Views: 3009

Answers (1)

sooper
sooper

Reputation: 6039

From what I've read here this is a known issue with Android when deploying in Release. The workaround is to point to the file with a uri:

{ uri: 'file:///pathto/file.html' }

Upvotes: 4

Related Questions