fix: disable prefetches for audits table (#11040)

This commit is contained in:
Michael Smith
2023-12-05 08:49:11 -05:00
committed by GitHub
parent 1b2ed5bc9b
commit dd1f8331de
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -19,5 +19,6 @@ export function paginatedAudits(
q: payload,
});
},
prefetch: false,
};
}
+12
View File
@@ -66,6 +66,12 @@ export type UsePaginatedQueryOptions<
* closest valid page.
*/
onInvalidPageChange?: (params: InvalidPageParams) => void;
/**
* Defaults to true. Allows you to disable prefetches for pages where making
* a request is very expensive.
*/
prefetch?: boolean;
};
/**
@@ -98,6 +104,7 @@ export function usePaginatedQuery<
onInvalidPageChange,
searchParams: outerSearchParams,
queryFn: outerQueryFn,
prefetch = true,
...extraOptions
} = options;
@@ -148,7 +155,12 @@ export function usePaginatedQuery<
const queryClient = useQueryClient();
const prefetchPage = useEffectEvent((newPage: number) => {
if (!prefetch) {
return;
}
const options = getQueryOptionsFromPage(newPage);
return queryClient.prefetchQuery(options);
});