Commit 3ef7887
authored
fix(query-core): abort fetch loop for infinite queries if getNextPageParam returns null or undefined (#7799)
The `fetchPage` function has a safeguard where it only returns the current data if pageParam == null, however, this means we still stay in the loop and call `getNextPageParam` unnecessarily.
This can be troublesome if you set `pages: Infinity` on queryClient.fetchInfiniteQuery to fetch an arbitrary amount of pages until the natural end is reached by returning null/undefined from getNextPageParam, because it would never actually escape the loop1 parent 34a5672 commit 3ef7887
File tree
2 files changed
+11
-2
lines changed- packages/query-core/src
- __tests__
2 files changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
| 749 | + | |
749 | 750 | | |
750 | 751 | | |
751 | 752 | | |
752 | 753 | | |
753 | | - | |
754 | | - | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
755 | 758 | | |
756 | 759 | | |
757 | 760 | | |
| |||
762 | 765 | | |
763 | 766 | | |
764 | 767 | | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
765 | 771 | | |
766 | 772 | | |
767 | 773 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
0 commit comments