bigbuffet-rw/packages/pl-hooks/lib/hooks/instance/use-instance.ts
marcin mikołajczak 9fef1d1f4e pl-hooks: Prefer kebab case for file names
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-23 15:27:02 +02:00

21 lines
595 B
TypeScript

import { useQuery } from '@tanstack/react-query';
import { instanceSchema } from 'pl-api';
import * as v from 'valibot';
import { usePlHooksApiClient } from 'pl-hooks/contexts/api-client';
import { usePlHooksQueryClient } from 'pl-hooks/contexts/query-client';
const placeholderData = v.parse(instanceSchema, {});
const useInstance = () => {
const { client } = usePlHooksApiClient();
const queryClient = usePlHooksQueryClient();
return useQuery({
queryKey: ['instance'],
queryFn: client.instance.getInstance,
placeholderData,
}, queryClient);
};
export { useInstance };