Skip to content

Commit

Permalink
doc: update type definitions for lazy query hooks to include reset me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
Tasin5541 committed Feb 8, 2025
1 parent 801d7ea commit cdb264f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/rtk-query/api/created-api/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ const [trigger, result, lastPromiseInfo] = api.useLazyGetPostsQuery(options)
```ts no-transpile
type UseLazyQuery = (
options?: UseLazyQueryOptions
) => [UseLazyQueryTrigger, UseQueryStateResult, UseLazyQueryLastPromiseInfo]
) => [UseLazyQueryTrigger, UseLazyQueryStateResult, UseLazyQueryLastPromiseInfo]

type UseLazyQueryOptions = {
pollingInterval?: number
Expand All @@ -506,7 +506,7 @@ type UseLazyQueryTrigger<T> = (arg: any, preferCacheValue?: boolean) => Promise<
updateSubscriptionOptions: (options: SubscriptionOptions) () => void // A method used to update the subscription options (eg. pollingInterval)
}

type UseQueryStateResult<T> = {
type UseLazyQueryStateResult<T> = {
// Base query state
originalArgs?: unknown // Arguments passed to the query
data?: T // The latest returned result regardless of trigger arg, if present
Expand All @@ -522,6 +522,8 @@ type UseQueryStateResult<T> = {
isFetching: false // Query is currently fetching, but might have data from an earlier request.
isSuccess: false // Query has data from a successful load.
isError: false // Query is currently in an "error" state.

reset: () => void // Resets the lazy query state to its initial uninitialized state. This will also remove the last result from the cache.
}

type UseLazyQueryLastPromiseInfo = {
Expand Down

0 comments on commit cdb264f

Please sign in to comment.