Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

skipToken.md

23 lines575 Bytes

const skipToken: unique symbol;

Defined in: packages/query-core/dist-ts/src/utils.d.ts:182

Sentinel value that can be passed as a query's queryFn to conditionally disable the query (equivalent to enabled: false) while preserving full type inference for the query's data. Unlike enabled: false, a query disabled via skipToken cannot be triggered with refetch.

Example

new QueryObserver(queryClient, {
  queryKey: ['post', postId],
  queryFn: postId != null ? () => fetchPost(postId) : skipToken,
})