Fix: correctly partial-match when calling truncateAndInvalidate() (#2088)

zio/stable
Paul Frazee 2023-12-04 17:53:22 -08:00 committed by GitHub
parent 160055e4f9
commit d07ea64434
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -2,9 +2,9 @@ import {QueryClient, QueryKey, InfiniteData} from '@tanstack/react-query'
export function truncateAndInvalidate<T = any>( export function truncateAndInvalidate<T = any>(
queryClient: QueryClient, queryClient: QueryClient,
querykey: QueryKey, queryKey: QueryKey,
) { ) {
queryClient.setQueryData<InfiniteData<T>>(querykey, data => { queryClient.setQueriesData<InfiniteData<T>>({queryKey}, data => {
if (data) { if (data) {
return { return {
pageParams: data.pageParams.slice(0, 1), pageParams: data.pageParams.slice(0, 1),
@ -13,5 +13,5 @@ export function truncateAndInvalidate<T = any>(
} }
return data return data
}) })
queryClient.invalidateQueries({queryKey: querykey}) queryClient.invalidateQueries({queryKey})
} }