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.

stopLoading() not working

See original GitHub issue

Bug description:

stopLoading() does not stop a tapped link from loading on Android.

I’m using react-native-webview with React Navigation. I’m trying to handle stacking webview screens using StackActions.push() to push the same route on to the stack. I’ve got it working fine on iOS, but on Android stopLoading() doesn’t appear to do anything. Tapping a link in page A opens up page B in a new view on the stack, but underneath page B has also opened in the first view too. So when you tap back, you see the same page again, and from there there’s no way to get back to the original page again. There doesn’t seem to be any way to prevent this.

In addition, I often find the stacked view opening twice when tapping a link.

Related issue: https://github.com/react-native-community/react-native-webview/issues/8

To Reproduce:

I’ve created a repository with the minimum code required for this issue to be reproduced. https://github.com/gavrichards/react-native-webview-stack The important code is in src/WebViewWrapper.js

Expected behavior:

stopLoading() should prevent a tapped link from loading in the current webview, and allow me to make it so the link is instead loaded in a stacked route.

Screenshots/Videos:

https://vimeo.com/368033141

Environment:

  • OS: Android
  • OS version: 10.0
  • react-native version: 0.61.2
  • react-native-webview version: 7.4.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:14

github_iconTop GitHub Comments

8reactions
lorenjohnsoncommented, Oct 28, 2022

react-router (web) history.push events are not triggering to the WebView due to another bug (https://github.com/react-native-webview/react-native-webview/issues/1197). I’m injecting a shim I found as a workaround in that issue and that does succeed in getting the state changes through to onNavigationStateChange.

However, those state changes don’t trigger onShouldStartLoadWithRequest. So currently I’m stuck with the shim and a forced webViewRef.current.goBack due to stopLoading not working in onNavigationStateChange for the links I wanted to intercept (block actually).

Summary: stopLoading isn’t working for either and I’m wondering why this issue was closed?

8reactions
xAirxcommented, Oct 23, 2019

I am experiencing the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

The method stopLoading of react-native-webview causes the ...
If I click on a link in that webview the URL will be opened in a the systems Browser as expected. The problem...
Read more >
stopLoading() | Apple Developer Documentation
Instance Method. stopLoading(). Stops loading all resources on the current page. iOS 8.0+ iPadOS 8.0+ macOS 10.10+ Mac Catalyst 13.0+. Declaration.
Read more >
StopLoading Method - Micro Focus
StopLoading is declared for the browser window. Action. Stops the browser from loading the current page. Availability. This functionality is supported only if ......
Read more >
stopLoading
stopLoading(). Stops loading the frame content. Synopsis: #include <WebFrame.h> virtual void stopLoading();. Description: Stops the current load operation.
Read more >
android.webkit.WebView.stopLoading java code examples
stopLoading (Showing top 20 results out of 378). origin: Rukey7/MvpApp ... @Override public void stopLoading() { if (!AgentWebUtils.
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