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.

Webview reloads when coming back on the page

See original GitHub issue

I have a NativeScript Page (i.e. main page) that contains an WebView and means to navigate to another NativeScript Page (i.e. about page).

If I got to the about page, and then come back to the main page, on android only, the webview on the main page will reload with the initial URL.

The fact that on iOS it works as expected leads me to believe it’s a bug.

I have this problem on two different applications that I’m working on now, and I also found another guy on StackOverflow with the same issue. If it is needed, I will also write a small example app that will illustrate the issue.

I’m using {N} with vanilla JS.

$ tns info
All NativeScript components versions information
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Component        β”‚ Current version β”‚ Latest version β”‚ Information      β”‚
β”‚ nativescript     β”‚ 3.1.2           β”‚ 3.1.3          β”‚ Update available β”‚
β”‚ tns-core-modules β”‚ 3.1.0           β”‚ 3.1.0          β”‚ Up to date       β”‚
β”‚ tns-android      β”‚ 3.1.1           β”‚ 3.1.1          β”‚ Up to date       β”‚
β”‚ tns-ios          β”‚ 3.1.0           β”‚ 3.1.0          β”‚ Up to date       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜



Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
hshristovcommented, Aug 9, 2017

@surdu I think you can use npm i tns-core-modules@next --save instead of tns plugin add.

1reaction
tsonevncommented, Aug 8, 2017

Hi @surdu, Thank you for your further investigation. Indeed while setting the value for the src property inline in the XML the WebView page will be reloaded every time, when you navigate back to the previous page. This is caused due to fact that the native WebView will be destroyed and recreated every time when you navigate to the page with WebView.

However, this behavior has been fixed in @next modules and you could test it on your side while following the described steps:

tns plugin remove tns-core-modules

tns plugin add tns-core-modules@next

also before rebuild delete node_modules and platforms folders

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Webview - Prevent Reload When Go Back to the App
How to prevent reload on webview when your back to the app? When tapping home key and then back to the app, the...
Read more >
WebView - Android Developers
Transportation object for returning WebView across thread boundaries. ... Gets whether the page can go back or forward the given number of steps....
Read more >
WebView - React Native
Go back one page in the web view's history. reload() ​. reload();.
Read more >
location.reload() - Web APIs | MDN
The location.reload() method reloads the current URL, like the Refresh button.
Read more >
Reset React Native WebView to initial url - Medium
return ( <WebView ref={r => this.webview = r} source={{ uri: yourInitialUrl }} /> ); } }. Ok, but if the user navigated X...
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