File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,20 @@ export function useInfiniteQuery(...args) {
2828 data . push ( await originalQueryFn ( ...args ) )
2929 rebuiltPageVariables . push ( args )
3030 } else {
31+ // get an up-to-date cursor based on the previous data set
32+ const nextCursor = getGetFetchMore ( ) ( data [ data . length - 1 ] , data ) ;
33+
34+ // break early if there's no next cursor
35+ // otherwise we'll start from the beginning
36+ // which will cause unwanted duplication
37+ if ( ! nextCursor ) {
38+ break ;
39+ }
40+
3141 const pageArgs = [
3242 // remove the last argument (the previously saved cursor)
3343 ...args . slice ( 0 , - 1 ) ,
34- // generate an up-to-date cursor based on the previous data set
35- getGetFetchMore ( ) ( data [ data . length - 1 ] , data ) ,
44+ nextCursor
3645 ]
3746
3847 data . push ( await originalQueryFn ( ...pageArgs ) )
You can’t perform that action at this time.
0 commit comments