Closed vlanemcev closed 4 months ago
To disable queries, now you can pass skipToken
as the option variables
to your custom query in v3.3.0. This will prevent the query from being executed.
import { skipToken } from '@tanstack/react-query'
const [name, setName] = useState<string | undefined>()
const result = usePost({
variables: id ? { id: id } : skipToken,
})
// and for useQueries example
const queries = useQueries({
queries: [usePost.getOptions(id ? { id: id } : skipToken)],
})
Okay, thanks!
Hi, thanks for this amazing library!
I'm curious how to use
skipToken
functionality withcreateQuery
function options. This is pretty useful forrefetch
preventing if we have our query disabled.https://tanstack.com/query/v5/docs/framework/react/guides/disabling-queries#typesafe-disabling-of-queries-using-skiptoken