Skip to content

Commit 4246309

Browse files
committed
fix properly pass abort signal of query
1 parent ca6841f commit 4246309

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

components/content-search/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const ContentSearch: React.FC<ContentSearchProps> = ({
121121
const { status, data, error, isFetching, isFetchingNextPage, fetchNextPage, hasNextPage } =
122122
useInfiniteQuery({
123123
queryKey: ['search', searchString, contentTypes.join(','), mode, perPage, queryFilter],
124-
queryFn: async ({ pageParam = 1 }) =>
124+
queryFn: async ({ pageParam = 1, signal }) =>
125125
fetchSearchResults({
126126
keyword: searchString,
127127
page: pageParam,
@@ -130,6 +130,7 @@ const ContentSearch: React.FC<ContentSearchProps> = ({
130130
contentTypes,
131131
queryFilter,
132132
excludeItems,
133+
signal,
133134
}),
134135
getNextPageParam: (lastPage) => lastPage.nextPage,
135136
getPreviousPageParam: (firstPage) => firstPage.previousPage,

components/content-search/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ interface FetchSearchResultsArgs {
132132
contentTypes: Array<string>;
133133
queryFilter: QueryFilter;
134134
excludeItems: Array<IdentifiableObject>;
135+
signal?: AbortSignal;
135136
}
136137

137138
export async function fetchSearchResults({
@@ -142,6 +143,7 @@ export async function fetchSearchResults({
142143
contentTypes,
143144
queryFilter,
144145
excludeItems,
146+
signal,
145147
}: FetchSearchResultsArgs) {
146148
const searchQueryString = prepareSearchQuery({
147149
keyword,
@@ -154,6 +156,7 @@ export async function fetchSearchResults({
154156
const response = await apiFetch<Response>({
155157
path: searchQueryString,
156158
parse: false,
159+
signal,
157160
});
158161

159162
const totalPages = parseInt(

0 commit comments

Comments
 (0)