TanStackT
TanStack3y ago
4 replies
uncertain-scarlet

Reusing queries and queryKey variable evaluation

If I include a variable in a query (like the column id for a table) and the components are generated dynamically like so

  const checkNumber = useQuery({
        queryKey: ['column', { type: 'exists' }, columnId],
        queryFn: checkColumn()
    });


if I elsewhere try to retrieve the value of the query using a value that I know was passed into the query as a key, like this:

  const checkNumber = useQuery({
        queryKey: ['column', { type: 'exists' }, "ab3452c"],
        queryFn: checkColumn()
    });


will the dynamically generated query and the manually invoked query match?
Was this page helpful?