(refocus) - Switch to visibilitychange api#1077
Conversation
🦋 Changeset detectedLatest commit: d249bd0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for picking this up! First on a small side-note, we document our changes for our automatically generated changelogs using "changeset" (that's what the comment above is about). Just check these instructions here on how to document a change here and probably mark this one as "minor": https://github.com/FormidableLabs/urql/blob/main/CONTRIBUTING.md#how-do-i-document-a-change-for-the-changelog |
Sorry, I should have read the contributing doc before submitting my PR 😅 |
Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
JoviDeCroock
left a comment
There was a problem hiding this comment.
Awesome work, thanks for picking this up!
Resolves #1063
Summary
Use the
visibilitychangeapi.Set of changes
focustovisibilitychangeapiI looked at SWR and react-query code and noticed that they refetch on both
focusandvisibilitychangeevents. As you can see in the video below,visibilitychangedoes not fire when we switch from one window to another (whilefocusdoes). It actually makes sense since the visibility of the document does not change. According to #1063,focushas some issues so I guess it's fine to only refetch onvisibilitychange?