Replies: 1 comment 2 replies
-
|
reconnect is for when you lose network connection (going offline) and then re-gaining it (going online again).
you can keep all the flags off and just do a |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Everyone.
I work on an app where we are careful to limit our api calls. General behavior we wish for is to cache data locally for as long as possible, and thus we use tanstack along with syncStoragePersister in order to save the data in the localstorage. If you refresh your browser, we wish to pull the data from the localstorage for as long as the data isn't considered stale, but then refetch on refresh if the data is stale when opening the app.
I thought setupping my query with
refetchOnReconnect: true, and every other refetch option to false would lead to this behavior. It however does not refetch the data from the api when the page reloads, and it serves the stale data from the localstorage instead. If I instead userefetchOnMount, the data is indeed refetched if i refresh my page and the data is stale.The problem with
refetchOnMount, is that the data will be refetched automatically once the data is stale if the user keeps browsing the application. In our case is it unnecessary, I would have preferred to avoid it.In the end of the day, my real question is:
What is
refetchOnReconnectused for? What is considered a reconnect? The documentation is not helping me understand, sadly :(thanks in advance to anybody who helps me understand <3
Beta Was this translation helpful? Give feedback.
All reactions