sbklS
Convex Community15mo ago
4 replies
sbkl

Uncaught Error: The arguments to a Convex function must be an object. Received: skip

Using convex-react-query, I noticed there is a new skip arguments that can be used to disable a query when the arguments is not available yet. But I get this error: Uncaught Error: The arguments to a Convex function must be an object. Received: skip. Which means the convex client complaining about the args. Looked at the code and normally the query shouldn't run at all. Any idea? Maybe I understand it wrong.

My code:
export function useGetDocument() {
  const params = useParams();
  const documentId = params.documentId as Id<"documents"> | undefined;
  const query = useQuery(
    convexQuery(
      api.documents.query.find,
      documentId
        ? {
            documentId: documentId as Id<"documents">,
          }
        : "skip",
    ),
  );

  return { documentId, ...query };
}
Was this page helpful?