question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android WebViews do not update when content contains #

See original GitHub issue

Description

If you have a webview that contains html with a # in it, the WebView will not be updated if the content after the # is changed on rerender. This issue only occurs with android devices (versions tested are noted below).

Reproduction Steps and Sample Code

Example: https://snack.expo.io/BJj62vVAx

  • Create a component which: ** has a state variable which is a string with a # in it ** displays that string as the (html) source of a webview ** has a button that changes the value of the state variable by modifying the content after the #. ( this can be seen in the example provided )
  • click on the button to update the string
  • Note that the new value of the string is not shown in the webview

Expected:

  • The WebView should rerender to show the new html it is given.

Solution

Not sure, however, it would be worth verifying this with other characters to see if any others cause this issue.

Additional Information

  • React Native version: 0.42.0 & 0.43.0
  • Platform: Android (5, 6 & 7) have not tried older versions.
  • Development Operating System: Mac OS Sierra
  • Dev tools: 2.2.2 Android SDK: 23

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
kidmysoulcommented, Mar 19, 2018

I have the same problem with @xerotolerant , the webview doesnot re-render when I have code in html like

body { color: #4a4a4a; }

Even when I comment out the style like

body { /*color: #4a4a4a;*/ } it doesnot work too.

And when I dropped the whole style , the content re-rendered . it only happened in android.So I have to change the color style to rgb(***)

I use “react-native”: “0.50.0”,

@hramos please re-open this issue because it’s a bug I think.

0reactions
fshaugecommented, Jul 21, 2018

A temporary solution in your React Native app is to call encodeURIComponent with the HTML before passing it to the WebView.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android WebView not refreshing after webpage content changes
The below two settings should be there to avoid webview caching to update the page without refresh settings.setCacheMode(WebSettings.
Read more >
The WebView does not refresh properly when it is passed ...
I needed to pass a WebView to another Activity, and I couldn't create a new WebView in the new Activity because the html...
Read more >
Webview API - Visual Studio Code
Use the Webview API to create fully customizable views within Visual Studio Code.
Read more >
WebView - .NET MAUI - Microsoft Learn
NET MAUI) WebView displays remote web pages, local HTML files, and HTML strings, in an app. The content displayed a WebView includes support ......
Read more >
Managing WebView objects - Android Developers
Note: The getCurrentWebViewPackage() method can return null if the device has been set up incorrectly, doesn't support using WebView (such ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found