Skip to content

Conversation

@pfeiffer
Copy link
Contributor

Summary

This PR fixes double-calling of onLoad on Android.
The LOAD event is triggered in visitRendered. The visitRendered callback is triggered both when restoring and when advancing by Hotwire Native.

The visitCompleted is called when a web page has been loaded in the WebView.

The onLoad callback could be fired twice - once via visitCompleted and once via visitRendered. This PR addresses that by only firing it via visitRendered which brings the behavior in-line with iOS.

Test plan

Add a log statement to onLoad. Test on Android and open a screen and navigate around.

Before

 WARN  [useOnLoad] CALLED with: {"title": "Home", "url": "https://some-page.com/home"}
 WARN  [useOnLoad] CALLED with: {"title": "Home", "url": "https://some-page.com/home"}

After

 WARN  [useOnLoad] CALLED with: {"title": "Home", "url": "https://some-page.com/home"}

The `LOAD` event is triggered in `visitRendered`. We do not need to also
call it in `visitCompleted`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant