Skip to content

Commit

Permalink
Reset pagination reference cache
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodyowl committed Jul 24, 2024
1 parent 65c65e3 commit 72dc624
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/react/usePagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,20 @@ const createPaginationHook = (direction: mode) => {
([serialized]) => serializedArg === serialized,
)
) {
connectionArgumentsRef.current = [
...connectionArgumentsRef.current,
[serializedArg, arg],
];
// if `before` or `after` argument is `null`, we're on the first page,
// reset the pagination
if (
"__connectionArguments" in connection &&
isRecord(connection.__connectionArguments) &&
connection.__connectionArguments[direction] == null
) {
connectionArgumentsRef.current = [[serializedArg, arg]];
} else {
connectionArgumentsRef.current = [
...connectionArgumentsRef.current,
[serializedArg, arg],
];
}
}
}

Expand Down

0 comments on commit 72dc624

Please sign in to comment.