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

skipToken.md

25 lines726 Bytes

1---
2id: skipToken
3title: skipToken
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8```ts
9const skipToken: typeof skipToken;
10```
11​
12Defined in: [packages/query-core/src/utils.ts:626](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L626)
13​
14Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent
15to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`,
16a query disabled via `skipToken` cannot be triggered with `refetch`.
17​
18## Example
19​
20```ts
21new QueryObserver(queryClient, {
22 queryKey: ['post', postId],
23 queryFn: postId != null ? () => fetchPost(postId) : skipToken,
24})
25```