You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
infiniteQuery continues to refetch data even if there are no more observers #1412
Describe the bug infiniteQuery continues to iterate and fetch all pages even after there are no more observers to consume the data. If the infiniteQuery contains a large set of pages (i.e. 100) this causes unnecessary network load and keeps references to variables for a long time.
To Reproduce
Steps to reproduce the behavior:
Open sample in CodeSandbox
Allow all pages to finish loading (up to 15 pages).
Open Console tab (bottom right) in CodeSandbox or browser console
Sample app will print Fetched page every time an API call is simulated
Click on Toggle button to unmount the component which calls useInfiniteQuery
Notice even though there are no more observers which consume the components query the infiniteQuery continues to fetch pages in the background.
Expected behavior
After all observers (i.e. React components) which consume an infiniteQuery go out of scope the infiniteQuery should stop fetching subsequent pages.
Screenshots
Desktop (please complete the following information):
OS: all
Browser: all
Version: all
Smartphone (please complete the following information):
changed the title [-]infiniteQuery continues to refetch data even there are no more observers[/-][+]infiniteQuery continues to refetch data even if there are no more observers[/+]on Dec 28, 2020
@boschni Thank you for addressing this issue. I noticed that with the latest update the CodeSandbox sample shows an error after the infinite query is cancelled and the React component is rendered again.
Please let me know if I've to change my code to consume the new changes.
Activity
jayakusumah commentedon Dec 27, 2020
same issue, I'm using nextjs and following the example
GermaVinsmoke commentedon Dec 28, 2020
Gave a
staleTimeof1000 * 60 * 60but then also it's fetching[-]infiniteQuery continues to refetch data even there are no more observers[/-][+]infiniteQuery continues to refetch data even if there are no more observers[/+]FMCorz commentedon Jan 6, 2021
Same issue.
Khufu-I commentedon Feb 8, 2021
@boschni Thank you for addressing this issue. I noticed that with the latest update the CodeSandbox sample shows an error after the infinite query is cancelled and the React component is rendered again.
Please let me know if I've to change my code to consume the new changes.