Skip to content

Commit

Permalink
Require initialPageParam value
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Oct 24, 2024
1 parent 0ed9cd2 commit dfb1093
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/toolkit/src/query/core/apiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type GetPreviousPageParamFunction<TPageParam, TQueryFnData> = (
) => TPageParam | undefined | null

export type InfiniteQueryConfigOptions<TQueryFnData, TPageParam> = {
initialPageParam: TPageParam
/**
* This function can be set to automatically get the previous cursor for infinite queries.
* The result will also be used to determine the value of `hasPreviousPage`.
Expand Down
3 changes: 2 additions & 1 deletion packages/toolkit/src/query/core/buildThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ export function buildThunks<
// Fetch first page
result = await fetchPage(
existingData,
existingData.pageParams[0] ?? arg.originalArgs,
existingData.pageParams[0] ??
endpointDefinition.infiniteQueryOptions.initialPageParam, // arg.originalArgs,
)

//original
Expand Down
1 change: 1 addition & 0 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
const queryStateResults = useInfiniteQueryState(
arg,
{
initialPageParam: options?.initialPageParam!,
getNextPageParam: options?.getNextPageParam!,
getPreviousPageParam: options?.getPreviousPageParam,
},
Expand Down

0 comments on commit dfb1093

Please sign in to comment.