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

skipToken.md

23 lines653 Bytes

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