mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
24 lines
631 B
TypeScript
24 lines
631 B
TypeScript
import { defaultShouldDehydrateQuery, QueryClient } from '@tanstack/react-query';
|
|
import { QUERY } from '@/lib/constants';
|
|
import { isProduction } from '@/lib/env';
|
|
|
|
export function createQueryClient() {
|
|
return new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: isProduction ? QUERY.STALE_TIME_DEFAULT : QUERY.STALE_TIME_DEFAULT_DEV,
|
|
},
|
|
dehydrate: {
|
|
shouldDehydrateQuery: (query) =>
|
|
defaultShouldDehydrateQuery(query) || query.state.status === 'pending',
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export enum QUERY_STATUS {
|
|
PENDING = 'pending',
|
|
SUCCESS = 'success',
|
|
ERROR = 'error',
|
|
}
|