mirror of
https://github.com/portainer/portainer.git
synced 2026-06-23 07:20:13 +00:00
0c2f07988a
Co-authored-by: Chaim Lev-Ari <chaim.lev-ari@portainer.io> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
740 B
TypeScript
26 lines
740 B
TypeScript
import { ComponentType } from 'react';
|
|
import { MutationCache, QueryCache, QueryClient } from '@tanstack/react-query';
|
|
|
|
import { withReactQuery } from '@/react-tools/withReactQuery';
|
|
|
|
export function withTestQueryProvider<T>(
|
|
WrappedComponent: ComponentType<T & JSX.IntrinsicAttributes>,
|
|
{
|
|
onMutationError,
|
|
onQueryError,
|
|
}: {
|
|
onMutationError?(error: unknown): void;
|
|
onQueryError?(error: unknown): void;
|
|
} = {}
|
|
) {
|
|
const testQueryClient = new QueryClient({
|
|
defaultOptions: { queries: { retry: false } },
|
|
queryCache: new QueryCache({ onError: onQueryError }),
|
|
mutationCache: new MutationCache({
|
|
onError: onMutationError,
|
|
}),
|
|
});
|
|
|
|
return withReactQuery(WrappedComponent, testQueryClient);
|
|
}
|