-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
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
infiniteQuerycontinues 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.
Desktop (please complete the following information):
- OS: all
- Browser: all
- Version: all
Smartphone (please complete the following information):
- Device: all
- OS: all
- Browser: all
- Version: all
Additional context
Possible code that controls this behaviour
FMCorz
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
