dify/web/service/use-base.ts

32 lines
544 B
TypeScript
Raw Normal View History

import type { QueryKey } from '@tanstack/react-query'
import {
useQueryClient,
} from '@tanstack/react-query'
export const useInvalid = (key?: QueryKey) => {
const queryClient = useQueryClient()
return () => {
if (!key)
return
queryClient.invalidateQueries(
{
queryKey: key,
},
)
}
}
2025-03-07 10:10:40 +00:00
export const useReset = (key?: QueryKey) => {
2025-03-07 10:10:40 +00:00
const queryClient = useQueryClient()
return () => {
if (!key)
return
2025-03-07 10:10:40 +00:00
queryClient.resetQueries(
{
queryKey: key,
},
)
}
}