Skip to content
Discussion options

You must be logged in to vote

hi @akshatmittal swr doesn't listen to DOM change or visible. and the hidden in refreshWhenHidden represents the visibility of current page/browser tab instead of some specific component.

so I think you can use Intersection_Observer_API to track the visibility of your hidden component, or you know the timestamp exactly when component slides into screen. then you can call mutate() or revalidate() to update state from swr.

or you can wrap your useSWR hook in a standalone component, which only renders when your component becomes visible to users. hope this can solve part of the problem.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@akshatmittal
Comment options

@bacchilu
Comment options

Answer selected by akshatmittal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants