You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the package in my React native application to load a HTML string.
<WebView
source={{
html: htmlString
}}
/>;
The htmlString has some links. When clicking on these links I need to prevent loading them and do a in-app navigation using react-navigator. This is the updated code,
const onWebViewNavigateStart = useCallback(
(newNavState: WebViewNavigation) => {
const { url } = newNavState;
if (!url) return;
// handle certain doctypes
if (url.startsWith("https://www.abcd.com/cat/")) {
if (webViewRef.current) {
webViewRef.current.stopLoading(); // <------- Here I try to stop loading
}
navigation.navigate("StackName", {
screen: "ScreenName",
params: {
// some params
},
});
return;
}
// rest of the code
On iOS this works fine but in Android, the webview will load the clicked url and after some seconds the onWebViewNavigateStart is called. Then it will trigger the clicked URL and navigate to the screen ( "ScreenName" ).
Here is the summary what happens in the app right now
Load the html string into the webview
Click on a link in webview content.
Loading clicked url into the webview
Trigger onWebViewNavigateStart
if condition full filled and navigate to the given screen.
What supposed to happen
Load the html string into the webview
Click on a link in webview content.
Trigger onWebViewNavigateStart
if condition full filled and navigate to the given screen.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using the package in my React native application to load a HTML string.
The
htmlString
has some links. When clicking on these links I need to prevent loading them and do a in-app navigation usingreact-navigator
. This is the updated code,And the declaration of callback function is,
On iOS this works fine but in Android, the webview will load the clicked url and after some seconds the
onWebViewNavigateStart
is called. Then it will trigger the clicked URL and navigate to the screen ( "ScreenName" ).Here is the summary what happens in the app right now
onWebViewNavigateStart
if
condition full filled and navigate to the given screen.What supposed to happen
onWebViewNavigateStart
if
condition full filled and navigate to the given screen.Beta Was this translation helpful? Give feedback.
All reactions