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.

onNavigationStateChange triggered twice when url change

See original GitHub issue

Bug description: when i an in www.a.com , and run window.location.href='www.b.com' , onNavigationStateChange triggered twice, and the two callback has the same url: ‘www.b.com’; and when i go back, onNavigationStateChange also triggered twice, and the url are all www.a.com

Expected behavior: onNavigationStateChange trigger only once on every url change

Screenshots/Videos:

Environment:

  • OS: android/ios
  • OS version:
  • react-native version: 0.62.2
  • react-native-webview version: 10.3.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

20reactions
iamrohitaggcommented, Jul 15, 2021

@atalshrivastava I’ve just checked, the object from onNavigationStateChange gives a property loading and I am calling the required function when loading is false.

2reactions
r-arvindcommented, Aug 8, 2021

@iamrohitagg’s method of using the loading variable seems to work for me too

Read more comments on GitHub >

github_iconTop Results From Across the Web

onNavigationStateChange triggered twice when url change
Bug description: when i an in www.a.com , and run window.location.href='www.b.com' , onNavigationStateChange triggered twice, ...
Read more >
onNavigationStateChange is rendering twice in react native ...
Whatsoever is in this function, everything is getting called twice. I am unable to figure out why this is happening??
Read more >
A brand new website interface for an even better experience!
onNavigationStateChange triggered twice when url change.
Read more >
Using WebView with React Navigation | by Damien Mason
To do that we're going to use onNavigationStateChange , and the first step ... which is that onNavigationStateChange is called twice , which ......
Read more >
onnavigationstatechange react native webview
Function that is invoked when the WebView has finished loading. onNavigationStateChange triggered twice when url change #1584 You could find ...
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