TanStackT
TanStack2y ago
8 replies
endless-jade

UseQueryOptions without providing a required `queryKey`

hello, is there a way to use UseQueryOptions without providing a required queryKey? im upgrading to v5 and in v4 this was never required. I am using a custom hook with react query

export const useCustomHook = (id: string, options?: UseQueryOptions<Group>) => {
    const { profile } = useAuth();

    return useQuery({
        queryKey: ...,
        queryFn: () => ...,
        ...options
    });
};

useCustomHook(id, {
  enabled: ... // queryKey is required here but I dont want to pass it
})
Was this page helpful?