Skip to content

Commit e5ef275

Browse files
tylersayshiTkDodo
andauthoredMar 28, 2025··
docs(queryClient): JSDoc hint for queryClient.getQueryData (#8862)
* docs(queryClient): JSDoc hint for queryClient.getQueryData follow up from: https://bsky.app/profile/tylur.dev/post/3llennpm4kk2z * Update packages/query-core/src/queryClient.ts * Update packages/query-core/src/queryClient.ts --------- Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
1 parent 72ca2e6 commit e5ef275

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

Diff for: ‎packages/query-core/src/queryClient.ts

+7
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ export class QueryClient {
119119
return this.#mutationCache.findAll({ ...filters, status: 'pending' }).length
120120
}
121121

122+
/**
123+
* Imperative (non-reactive) way to retrieve data for a QueryKey.
124+
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
125+
*
126+
* Hint: Do not use this function inside a component, because it won't receive updates.
127+
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
128+
*/
122129
getQueryData<
123130
TQueryFnData = unknown,
124131
TTaggedQueryKey extends QueryKey = QueryKey,

0 commit comments

Comments
 (0)
Please sign in to comment.