-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent polling when browser is offline #203
Conversation
Maybe it will be great to detect when the user is back online to trigger a revalidation. |
Let me know if you also run into problems. Update: turns out the hook warning was indeed because of extraneous dependencies: this fix seems to work as intended after all 😊 |
Thanks a lot! Could you also create an option for it (same as |
@quietshu no problem! Added as a config option. I also took @sergiodxa’s suggestion and added an additional |
It just dawned on me we didn't have this capability. That's epic @daneden … |
Thank you @daneden ! |
Published in |
I love
useSwr
! I’m using it to build a London Underground status site.While testing the app on slow/no network speeds, I noticed that
useSwr
will continue polling endpoints even if the navigator is offline. This PR adds an additional boolean check in thetick
function to ensure that requests aren’t sent if the browser is offline.