stopLoading() not working
See original GitHub issueBug 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:
Environment:
- OS: Android
- OS version: 10.0
- react-native version: 0.61.2
- react-native-webview version: 7.4.3
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:14
Top GitHub Comments
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 toonNavigationStateChange
.However, those state changes don’t trigger
onShouldStartLoadWithRequest
. So currently I’m stuck with the shim and a forcedwebViewRef.current.goBack
due tostopLoading
not working inonNavigationStateChange
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?I am experiencing the same issue