SW
SW
CCConvex Community
Created by SW on 11/20/2024 in #support-community
Disabling query with TanStack Query
I am fetching data using convex query with TanStack query in my React project. I want to disable running query by condition. Here is the code.
const { data: fileUrl } = useQuery({
...convexQuery(api.tables.files.getFileUrl, {
fileId: selectedFileId as Id<"files">,
}),
enabled: !!selectedFileId,
});
}
const { data: fileUrl } = useQuery({
...convexQuery(api.tables.files.getFileUrl, {
fileId: selectedFileId as Id<"files">,
}),
enabled: !!selectedFileId,
});
}
So I want to run query only when select file. But it throws an error to convex log when the page is refreshed because the fileId is not immediately available: ArgumentValidationError: Value does not match validator. Path: .fileId Value: null Validator: v.id("files") How can I solve it?
5 replies