Debian Codegraph @

install/freeipa-webui/node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts

raw
1 import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
2 import { QueryDefinition, InfiniteQueryDefinition, MutationDefinition, QueryArgFrom, SkipToken, BaseQueryFn, SubscriptionOptions, QueryActionCreatorResult, TSHelpersNoInfer, TSHelpersId, TSHelpersOverride, QueryStatus, InfiniteQueryArgFrom, MutationResultSelectorResult, MutationActionCreatorResult, QuerySubState, ResultTypeFrom, InfiniteQueryActionCreatorResult, PageParamFrom, InfiniteQuerySubState, EndpointDefinitions, DefinitionType, QueryKeys, PrefetchOptions, Module, Api, setupListeners } from '@reduxjs/toolkit/query';
3 export * from '@reduxjs/toolkit/query';
4 import * as react_redux from 'react-redux';
5 import { ReactReduxContextValue } from 'react-redux';
6 import { createSelector } from 'reselect';
7 import * as React from 'react';
8 import { Context } from 'react';
9
10 type InfiniteData<DataType, PageParam> = {
11 pages: Array<DataType>;
12 pageParams: Array<PageParam>;
13 };
14 type InfiniteQueryDirection = 'forward' | 'backward';
15
16 export declare const UNINITIALIZED_VALUE: unique symbol;
17 type UninitializedValue = typeof UNINITIALIZED_VALUE;
18
19 type QueryHooks<Definition extends QueryDefinition<any, any, any, any, any>> = {
20 useQuery: UseQuery<Definition>;
21 useLazyQuery: UseLazyQuery<Definition>;
22 useQuerySubscription: UseQuerySubscription<Definition>;
23 useLazyQuerySubscription: UseLazyQuerySubscription<Definition>;
24 useQueryState: UseQueryState<Definition>;
25 };
26 type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {
27 useInfiniteQuery: UseInfiniteQuery<Definition>;
28 useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;
29 useInfiniteQueryState: UseInfiniteQueryState<Definition>;
30 };
31 type MutationHooks<Definition extends MutationDefinition<any, any, any, any, any>> = {
32 useMutation: UseMutation<Definition>;
33 };
34 /**
35 * A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
36 *
37 * The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.
38 *
39 * This hook combines the functionality of both [`useQueryState`](#usequerystate) and [`useQuerySubscription`](#usequerysubscription) together, and is intended to be used in the majority of situations.
40 *
41 * #### Features
42 *
43 * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
44 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
45 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
46 * - Returns the latest request status and cached data from the Redux store
47 * - Re-renders as the request status changes and data becomes available
48 */
49 type UseQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions & UseQueryStateOptions<D, R>) => UseQueryHookResult<D, R>;
50 type TypedUseQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
51 type UseQueryHookResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & UseQuerySubscriptionResult<D>;
52 /**
53 * Helper type to manually type the result
54 * of the `useQuery` hook in userland code.
55 */
56 type TypedUseQueryHookResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery, R> & TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery>;
57 type UseQuerySubscriptionOptions = SubscriptionOptions & {
58 /**
59 * Prevents a query from automatically running.
60 *
61 * @remarks
62 * When `skip` is true (or `skipToken` is passed in as `arg`):
63 *
64 * - **If the query has cached data:**
65 * * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
66 * * The query will have a status of `uninitialized`
67 * * If `skip: false` is set after the initial load, the cached result will be used
68 * - **If the query does not have cached data:**
69 * * The query will have a status of `uninitialized`
70 * * The query will not exist in the state when viewed with the dev tools
71 * * The query will not automatically fetch on mount
72 * * The query will not automatically run when additional components with the same query are added that do run
73 *
74 * @example
75 * ```tsx
76 * // codeblock-meta no-transpile title="Skip example"
77 * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
78 * const { data, error, status } = useGetPokemonByNameQuery(name, {
79 * skip,
80 * });
81 *
82 * return (
83 * <div>
84 * {name} - {status}
85 * </div>
86 * );
87 * };
88 * ```
89 */
90 skip?: boolean;
91 /**
92 * Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.
93 * - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
94 * - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.
95 * - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.
96 *
97 * If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
98 */
99 refetchOnMountOrArgChange?: boolean | number;
100 };
101 /**
102 * A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.
103 *
104 * The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.
105 *
106 * Note that this hook does not return a request status or cached data. For that use-case, see [`useQuery`](#usequery) or [`useQueryState`](#usequerystate).
107 *
108 * #### Features
109 *
110 * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
111 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
112 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
113 */
114 type UseQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions) => UseQuerySubscriptionResult<D>;
115 type TypedUseQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
116 type UseQuerySubscriptionResult<D extends QueryDefinition<any, any, any, any>> = Pick<QueryActionCreatorResult<D>, 'refetch'>;
117 /**
118 * Helper type to manually type the result
119 * of the `useQuerySubscription` hook in userland code.
120 */
121 type TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscriptionResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
122 type UseLazyQueryLastPromiseInfo<D extends QueryDefinition<any, any, any, any>> = {
123 lastArg: QueryArgFrom<D>;
124 };
125 /**
126 * A React hook similar to [`useQuery`](#usequery), but with manual control over when the data fetching occurs.
127 *
128 * This hook includes the functionality of [`useLazyQuerySubscription`](#uselazyquerysubscription).
129 *
130 * #### Features
131 *
132 * - Manual control over firing a request to retrieve data
133 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
134 * - Returns the latest request status and cached data from the Redux store
135 * - Re-renders as the request status changes and data becomes available
136 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once
137 *
138 * #### Note
139 *
140 * When the trigger function returned from a LazyQuery is called, it always initiates a new request to the server even if there is cached data. Set `preferCacheValue`(the second argument to the function) as `true` if you want it to immediately return a cached value if one exists.
141 */
142 type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>) => [
143 LazyQueryTrigger<D>,
144 UseLazyQueryStateResult<D, R>,
145 UseLazyQueryLastPromiseInfo<D>
146 ];
147 type TypedUseLazyQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
148 type UseLazyQueryStateResult<D extends QueryDefinition<any, any, any, any>, R = UseQueryStateDefaultResult<D>> = UseQueryStateResult<D, R> & {
149 /**
150 * Resets the hook state to its initial `uninitialized` state.
151 * This will also remove the last result from the cache.
152 */
153 reset: () => void;
154 };
155 /**
156 * Helper type to manually type the result
157 * of the `useLazyQuery` hook in userland code.
158 */
159 type TypedUseLazyQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseLazyQueryStateResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
160 type LazyQueryTrigger<D extends QueryDefinition<any, any, any, any>> = {
161 /**
162 * Triggers a lazy query.
163 *
164 * By default, this will start a new request even if there is already a value in the cache.
165 * If you want to use the cache value and only start a request if there is no cache value, set the second argument to `true`.
166 *
167 * @remarks
168 * If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
169 *
170 * @example
171 * ```ts
172 * // codeblock-meta title="Using .unwrap with async await"
173 * try {
174 * const payload = await getUserById(1).unwrap();
175 * console.log('fulfilled', payload)
176 * } catch (error) {
177 * console.error('rejected', error);
178 * }
179 * ```
180 */
181 (arg: QueryArgFrom<D>, preferCacheValue?: boolean): QueryActionCreatorResult<D>;
182 };
183 type TypedLazyQueryTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = LazyQueryTrigger<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
184 /**
185 * A React hook similar to [`useQuerySubscription`](#usequerysubscription), but with manual control over when the data fetching occurs.
186 *
187 * Note that this hook does not return a request status or cached data. For that use-case, see [`useLazyQuery`](#uselazyquery).
188 *
189 * #### Features
190 *
191 * - Manual control over firing a request to retrieve data
192 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
193 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met and the fetch has been manually called at least once
194 */
195 type UseLazyQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (options?: SubscriptionOptions) => readonly [
196 LazyQueryTrigger<D>,
197 QueryArgFrom<D> | UninitializedValue,
198 {
199 reset: () => void;
200 }
201 ];
202 type TypedUseLazyQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
203 /**
204 * @internal
205 */
206 type QueryStateSelector<R extends Record<string, any>, D extends QueryDefinition<any, any, any, any>> = (state: UseQueryStateDefaultResult<D>) => R;
207 /**
208 * Provides a way to define a strongly-typed version of
209 * {@linkcode QueryStateSelector} for use with a specific query.
210 * This is useful for scenarios where you want to create a "pre-typed"
211 * {@linkcode UseQueryStateOptions.selectFromResult | selectFromResult}
212 * function.
213 *
214 * @example
215 * <caption>#### __Create a strongly-typed `selectFromResult` selector function__</caption>
216 *
217 * ```tsx
218 * import type { TypedQueryStateSelector } from '@reduxjs/toolkit/query/react'
219 * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
220 *
221 * type Post = {
222 * id: number
223 * title: string
224 * }
225 *
226 * type PostsApiResponse = {
227 * posts: Post[]
228 * total: number
229 * skip: number
230 * limit: number
231 * }
232 *
233 * type QueryArgument = number | undefined
234 *
235 * type BaseQueryFunction = ReturnType<typeof fetchBaseQuery>
236 *
237 * type SelectedResult = Pick<PostsApiResponse, 'posts'>
238 *
239 * const postsApiSlice = createApi({
240 * baseQuery: fetchBaseQuery({ baseUrl: 'https://dummyjson.com/posts' }),
241 * reducerPath: 'postsApi',
242 * tagTypes: ['Posts'],
243 * endpoints: (build) => ({
244 * getPosts: build.query<PostsApiResponse, QueryArgument>({
245 * query: (limit = 5) => `?limit=${limit}&select=title`,
246 * }),
247 * }),
248 * })
249 *
250 * const { useGetPostsQuery } = postsApiSlice
251 *
252 * function PostById({ id }: { id: number }) {
253 * const { post } = useGetPostsQuery(undefined, {
254 * selectFromResult: (state) => ({
255 * post: state.data?.posts.find((post) => post.id === id),
256 * }),
257 * })
258 *
259 * return <li>{post?.title}</li>
260 * }
261 *
262 * const EMPTY_ARRAY: Post[] = []
263 *
264 * const typedSelectFromResult: TypedQueryStateSelector<
265 * PostsApiResponse,
266 * QueryArgument,
267 * BaseQueryFunction,
268 * SelectedResult
269 * > = (state) => ({ posts: state.data?.posts ?? EMPTY_ARRAY })
270 *
271 * function PostsList() {
272 * const { posts } = useGetPostsQuery(undefined, {
273 * selectFromResult: typedSelectFromResult,
274 * })
275 *
276 * return (
277 * <div>
278 * <ul>
279 * {posts.map((post) => (
280 * <PostById key={post.id} id={post.id} />
281 * ))}
282 * </ul>
283 * </div>
284 * )
285 * }
286 * ```
287 *
288 * @template ResultType - The type of the result `data` returned by the query.
289 * @template QueryArgumentType - The type of the argument passed into the query.
290 * @template BaseQueryFunctionType - The type of the base query function being used.
291 * @template SelectedResultType - The type of the selected result returned by the __`selectFromResult`__ function.
292 *
293 * @since 2.3.0
294 * @public
295 */
296 type TypedQueryStateSelector<ResultType, QueryArgumentType, BaseQueryFunctionType extends BaseQueryFn, SelectedResultType extends Record<string, any> = UseQueryStateDefaultResult<QueryDefinition<QueryArgumentType, BaseQueryFunctionType, string, ResultType, string>>> = QueryStateSelector<SelectedResultType, QueryDefinition<QueryArgumentType, BaseQueryFunctionType, string, ResultType, string>>;
297 /**
298 * A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
299 *
300 * Note that this hook does not trigger fetching new data. For that use-case, see [`useQuery`](#usequery) or [`useQuerySubscription`](#usequerysubscription).
301 *
302 * #### Features
303 *
304 * - Returns the latest request status and cached data from the Redux store
305 * - Re-renders as the request status changes and data becomes available
306 */
307 type UseQueryState<D extends QueryDefinition<any, any, any, any>> = <R extends Record<string, any> = UseQueryStateDefaultResult<D>>(arg: QueryArgFrom<D> | SkipToken, options?: UseQueryStateOptions<D, R>) => UseQueryStateResult<D, R>;
308 type TypedUseQueryState<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQueryState<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
309 /**
310 * @internal
311 */
312 type UseQueryStateOptions<D extends QueryDefinition<any, any, any, any>, R extends Record<string, any>> = {
313 /**
314 * Prevents a query from automatically running.
315 *
316 * @remarks
317 * When skip is true:
318 *
319 * - **If the query has cached data:**
320 * * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
321 * * The query will have a status of `uninitialized`
322 * * If `skip: false` is set after skipping the initial load, the cached result will be used
323 * - **If the query does not have cached data:**
324 * * The query will have a status of `uninitialized`
325 * * The query will not exist in the state when viewed with the dev tools
326 * * The query will not automatically fetch on mount
327 * * The query will not automatically run when additional components with the same query are added that do run
328 *
329 * @example
330 * ```ts
331 * // codeblock-meta title="Skip example"
332 * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
333 * const { data, error, status } = useGetPokemonByNameQuery(name, {
334 * skip,
335 * });
336 *
337 * return (
338 * <div>
339 * {name} - {status}
340 * </div>
341 * );
342 * };
343 * ```
344 */
345 skip?: boolean;
346 /**
347 * `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
348 * When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
349 * If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
350 *
351 * @example
352 * ```ts
353 * // codeblock-meta title="Using selectFromResult to extract a single result"
354 * function PostsList() {
355 * const { data: posts } = api.useGetPostsQuery();
356 *
357 * return (
358 * <ul>
359 * {posts?.data?.map((post) => (
360 * <PostById key={post.id} id={post.id} />
361 * ))}
362 * </ul>
363 * );
364 * }
365 *
366 * function PostById({ id }: { id: number }) {
367 * // Will select the post with the given id, and will only rerender if the given posts data changes
368 * const { post } = api.useGetPostsQuery(undefined, {
369 * selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
370 * });
371 *
372 * return <li>{post?.name}</li>;
373 * }
374 * ```
375 */
376 selectFromResult?: QueryStateSelector<R, D>;
377 };
378 /**
379 * Provides a way to define a "pre-typed" version of
380 * {@linkcode UseQueryStateOptions} with specific options for a given query.
381 * This is particularly useful for setting default query behaviors such as
382 * refetching strategies, which can be overridden as needed.
383 *
384 * @example
385 * <caption>#### __Create a `useQuery` hook with default options__</caption>
386 *
387 * ```ts
388 * import type {
389 * SubscriptionOptions,
390 * TypedUseQueryStateOptions,
391 * } from '@reduxjs/toolkit/query/react'
392 * import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
393 *
394 * type Post = {
395 * id: number
396 * name: string
397 * }
398 *
399 * const api = createApi({
400 * baseQuery: fetchBaseQuery({ baseUrl: '/' }),
401 * tagTypes: ['Post'],
402 * endpoints: (build) => ({
403 * getPosts: build.query<Post[], void>({
404 * query: () => 'posts',
405 * }),
406 * }),
407 * })
408 *
409 * const { useGetPostsQuery } = api
410 *
411 * export const useGetPostsQueryWithDefaults = <
412 * SelectedResult extends Record<string, any>,
413 * >(
414 * overrideOptions: TypedUseQueryStateOptions<
415 * Post[],
416 * void,
417 * ReturnType<typeof fetchBaseQuery>,
418 * SelectedResult
419 * > &
420 * SubscriptionOptions,
421 * ) =>
422 * useGetPostsQuery(undefined, {
423 * // Insert default options here
424 *
425 * refetchOnMountOrArgChange: true,
426 * refetchOnFocus: true,
427 * ...overrideOptions,
428 * })
429 * ```
430 *
431 * @template ResultType - The type of the result `data` returned by the query.
432 * @template QueryArg - The type of the argument passed into the query.
433 * @template BaseQuery - The type of the base query function being used.
434 * @template SelectedResult - The type of the selected result returned by the __`selectFromResult`__ function.
435 *
436 * @since 2.2.8
437 * @public
438 */
439 type TypedUseQueryStateOptions<ResultType, QueryArg, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseQueryStateOptions<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, SelectedResult>;
440 type UseQueryStateResult<_ extends QueryDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R>;
441 /**
442 * Helper type to manually type the result
443 * of the `useQueryState` hook in userland code.
444 */
445 type TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TSHelpersNoInfer<R>;
446 type UseQueryStateBaseResult<D extends QueryDefinition<any, any, any, any>> = QuerySubState<D> & {
447 /**
448 * Where `data` tries to hold data as much as possible, also re-using
449 * data from the last arguments passed into the hook, this property
450 * will always contain the received data from the query, for the current query arguments.
451 */
452 currentData?: ResultTypeFrom<D>;
453 /**
454 * Query has not started yet.
455 */
456 isUninitialized: false;
457 /**
458 * Query is currently loading for the first time. No data yet.
459 */
460 isLoading: false;
461 /**
462 * Query is currently fetching, but might have data from an earlier request.
463 */
464 isFetching: false;
465 /**
466 * Query has data from a successful load.
467 */
468 isSuccess: false;
469 /**
470 * Query is currently in "error" state.
471 */
472 isError: false;
473 };
474 type UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseQueryStateBaseResult<D>, {
475 status: QueryStatus.uninitialized;
476 }>, {
477 isUninitialized: true;
478 }> | TSHelpersOverride<UseQueryStateBaseResult<D>, {
479 isLoading: true;
480 isFetching: boolean;
481 data: undefined;
482 } | ({
483 isSuccess: true;
484 isFetching: true;
485 error: undefined;
486 } & Required<Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
487 isSuccess: true;
488 isFetching: false;
489 error: undefined;
490 } & Required<Pick<UseQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
491 isError: true;
492 } & Required<Pick<UseQueryStateBaseResult<D>, 'error'>>)>> & {
493 /**
494 * @deprecated Included for completeness, but discouraged.
495 * Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
496 * and `isUninitialized` flags instead
497 */
498 status: QueryStatus;
499 };
500 type LazyInfiniteQueryTrigger<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
501 /**
502 * Triggers a lazy query.
503 *
504 * By default, this will start a new request even if there is already a value in the cache.
505 * If you want to use the cache value and only start a request if there is no cache value, set the second argument to `true`.
506 *
507 * @remarks
508 * If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
509 *
510 * @example
511 * ```ts
512 * // codeblock-meta title="Using .unwrap with async await"
513 * try {
514 * const payload = await getUserById(1).unwrap();
515 * console.log('fulfilled', payload)
516 * } catch (error) {
517 * console.error('rejected', error);
518 * }
519 * ```
520 */
521 (arg: QueryArgFrom<D>, direction: InfiniteQueryDirection): InfiniteQueryActionCreatorResult<D>;
522 };
523 type TypedLazyInfiniteQueryTrigger<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = LazyInfiniteQueryTrigger<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
524 type UseInfiniteQuerySubscriptionOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>> = SubscriptionOptions & {
525 /**
526 * Prevents a query from automatically running.
527 *
528 * @remarks
529 * When `skip` is true (or `skipToken` is passed in as `arg`):
530 *
531 * - **If the query has cached data:**
532 * * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
533 * * The query will have a status of `uninitialized`
534 * * If `skip: false` is set after the initial load, the cached result will be used
535 * - **If the query does not have cached data:**
536 * * The query will have a status of `uninitialized`
537 * * The query will not exist in the state when viewed with the dev tools
538 * * The query will not automatically fetch on mount
539 * * The query will not automatically run when additional components with the same query are added that do run
540 *
541 * @example
542 * ```tsx
543 * // codeblock-meta no-transpile title="Skip example"
544 * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
545 * const { data, error, status } = useGetPokemonByNameQuery(name, {
546 * skip,
547 * });
548 *
549 * return (
550 * <div>
551 * {name} - {status}
552 * </div>
553 * );
554 * };
555 * ```
556 */
557 skip?: boolean;
558 /**
559 * Defaults to `false`. This setting allows you to control whether if a cached result is already available, RTK Query will only serve a cached result, or if it should `refetch` when set to `true` or if an adequate amount of time has passed since the last successful query result.
560 * - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
561 * - `true` - Will always refetch when a new subscriber to a query is added. Behaves the same as calling the `refetch` callback or passing `forceRefetch: true` in the action creator.
562 * - `number` - **Value is in seconds**. If a number is provided and there is an existing query in the cache, it will compare the current time vs the last fulfilled timestamp, and only refetch if enough time has elapsed.
563 *
564 * If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
565 */
566 refetchOnMountOrArgChange?: boolean | number;
567 initialPageParam?: PageParamFrom<D>;
568 };
569 type TypedUseInfiniteQuerySubscription<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscription<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
570 type UseInfiniteQuerySubscriptionResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = Pick<InfiniteQueryActionCreatorResult<D>, 'refetch'> & {
571 trigger: LazyInfiniteQueryTrigger<D>;
572 fetchNextPage: () => InfiniteQueryActionCreatorResult<D>;
573 fetchPreviousPage: () => InfiniteQueryActionCreatorResult<D>;
574 };
575 /**
576 * Helper type to manually type the result
577 * of the `useQuerySubscription` hook in userland code.
578 */
579 type TypedUseInfiniteQuerySubscriptionResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscriptionResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
580 type InfiniteQueryStateSelector<R extends Record<string, any>, D extends InfiniteQueryDefinition<any, any, any, any, any>> = (state: UseInfiniteQueryStateDefaultResult<D>) => R;
581 type TypedInfiniteQueryStateSelector<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = InfiniteQueryStateSelector<SelectedResult, InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
582 /**
583 * A React hook that automatically triggers fetches of data from an endpoint, 'subscribes' the component to the cached data, and reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available. Additionally, it will cache multiple "pages" worth of responses within a single cache entry, and allows fetching more pages forwards and backwards from the current cached pages.
584 *
585 * The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already, and the hook will return the data for that query arg once it's available.
586 *
587 * The `data` field will be a `{pages: Data[], pageParams: PageParam[]}` structure containing all fetched page responses and the corresponding page param values for each page. You may use this to render individual pages, combine all pages into a single infinite list, or other display logic as needed.
588 *
589 * This hook combines the functionality of both [`useInfiniteQueryState`](#useinfinitequerystate) and [`useInfiniteQuerySubscription`](#useinfinitequerysubscription) together, and is intended to be used in the majority of situations.
590 *
591 * As with normal query hooks, `skipToken` is a valid argument that will skip the query from executing.
592 *
593 * By default, the initial request will use the `initialPageParam` value that was defined on the infinite query endpoint. If you want to start from a different value, you can pass `initialPageParam` as part of the hook options to override that initial request value.
594 *
595 * Use the returned `fetchNextPage` and `fetchPreviousPage` methods on the hook result object to trigger fetches forwards and backwards. These will always calculate the next or previous page param based on the current cached pages and the provided `getNext/PreviousPageParam` callbacks defined in the endpoint.
596 *
597 *
598 * #### Features
599 *
600 * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
601 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
602 * - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
603 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
604 * - Returns the latest request status and cached data from the Redux store
605 * - Re-renders as the request status changes and data becomes available
606 */
607 type UseInfiniteQuery<D extends InfiniteQueryDefinition<any, any, any, any, any>> = <R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<D>>(arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D> & UseInfiniteQueryStateOptions<D, R>) => UseInfiniteQueryHookResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'fetchNextPage' | 'fetchPreviousPage'>;
608 type TypedUseInfiniteQuery<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuery<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
609 /**
610 * A React hook that reads the request status and cached data from the Redux store. The component will re-render as the loading status changes and the data becomes available.
611 *
612 * Note that this hook does not trigger fetching new data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQuerySubscription`](#useinfinitequerysubscription).
613 *
614 * #### Features
615 *
616 * - Returns the latest request status and cached data from the Redux store
617 * - Re-renders as the request status changes and data becomes available
618 */
619 type UseInfiniteQueryState<D extends InfiniteQueryDefinition<any, any, any, any, any>> = <R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<D>>(arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQueryStateOptions<D, R>) => UseInfiniteQueryStateResult<D, R>;
620 type TypedUseInfiniteQueryState<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQueryState<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
621 /**
622 * A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data. Additionally, it will cache multiple "pages" worth of responses within a single cache entry, and allows fetching more pages forwards and backwards from the current cached pages.
623 *
624 * The query arg is used as a cache key. Changing the query arg will tell the hook to re-fetch the data if it does not exist in the cache already.
625 *
626 * Note that this hook does not return a request status or cached data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQueryState`](#useinfinitequerystate).
627 *
628 * #### Features
629 *
630 * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
631 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
632 * - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
633 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
634 */
635 type UseInfiniteQuerySubscription<D extends InfiniteQueryDefinition<any, any, any, any, any>> = (arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D>) => UseInfiniteQuerySubscriptionResult<D>;
636 type UseInfiniteQueryHookResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = UseInfiniteQueryStateResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'refetch'>;
637 type TypedUseInfiniteQueryHookResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, R extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryHookResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, R>;
638 type UseInfiniteQueryStateOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>, R extends Record<string, any>> = {
639 /**
640 * Prevents a query from automatically running.
641 *
642 * @remarks
643 * When skip is true:
644 *
645 * - **If the query has cached data:**
646 * * The cached data **will not be used** on the initial load, and will ignore updates from any identical query until the `skip` condition is removed
647 * * The query will have a status of `uninitialized`
648 * * If `skip: false` is set after skipping the initial load, the cached result will be used
649 * - **If the query does not have cached data:**
650 * * The query will have a status of `uninitialized`
651 * * The query will not exist in the state when viewed with the dev tools
652 * * The query will not automatically fetch on mount
653 * * The query will not automatically run when additional components with the same query are added that do run
654 *
655 * @example
656 * ```ts
657 * // codeblock-meta title="Skip example"
658 * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
659 * const { data, error, status } = useGetPokemonByNameQuery(name, {
660 * skip,
661 * });
662 *
663 * return (
664 * <div>
665 * {name} - {status}
666 * </div>
667 * );
668 * };
669 * ```
670 */
671 skip?: boolean;
672 /**
673 * `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
674 * When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
675 * If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
676 *
677 * @example
678 * ```ts
679 * // codeblock-meta title="Using selectFromResult to extract a single result"
680 * function PostsList() {
681 * const { data: posts } = api.useGetPostsQuery();
682 *
683 * return (
684 * <ul>
685 * {posts?.data?.map((post) => (
686 * <PostById key={post.id} id={post.id} />
687 * ))}
688 * </ul>
689 * );
690 * }
691 *
692 * function PostById({ id }: { id: number }) {
693 * // Will select the post with the given id, and will only rerender if the given posts data changes
694 * const { post } = api.useGetPostsQuery(undefined, {
695 * selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
696 * });
697 *
698 * return <li>{post?.name}</li>;
699 * }
700 * ```
701 */
702 selectFromResult?: InfiniteQueryStateSelector<R, D>;
703 };
704 type TypedUseInfiniteQueryStateOptions<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, SelectedResult extends Record<string, any> = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryStateOptions<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, SelectedResult>;
705 type UseInfiniteQueryStateResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = TSHelpersNoInfer<R>;
706 type TypedUseInfiniteQueryStateResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn, R = UseInfiniteQueryStateDefaultResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>> = UseInfiniteQueryStateResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>, R>;
707 type UseInfiniteQueryStateBaseResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = InfiniteQuerySubState<D> & {
708 /**
709 * Where `data` tries to hold data as much as possible, also re-using
710 * data from the last arguments passed into the hook, this property
711 * will always contain the received data from the query, for the current query arguments.
712 */
713 currentData?: InfiniteData<ResultTypeFrom<D>, PageParamFrom<D>>;
714 /**
715 * Query has not started yet.
716 */
717 isUninitialized: false;
718 /**
719 * Query is currently loading for the first time. No data yet.
720 */
721 isLoading: false;
722 /**
723 * Query is currently fetching, but might have data from an earlier request.
724 */
725 isFetching: false;
726 /**
727 * Query has data from a successful load.
728 */
729 isSuccess: false;
730 /**
731 * Query is currently in "error" state.
732 */
733 isError: false;
734 hasNextPage: false;
735 hasPreviousPage: false;
736 isFetchingNextPage: false;
737 isFetchingPreviousPage: false;
738 };
739 type UseInfiniteQueryStateDefaultResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseInfiniteQueryStateBaseResult<D>, {
740 status: QueryStatus.uninitialized;
741 }>, {
742 isUninitialized: true;
743 }> | TSHelpersOverride<UseInfiniteQueryStateBaseResult<D>, {
744 isLoading: true;
745 isFetching: boolean;
746 data: undefined;
747 } | ({
748 isSuccess: true;
749 isFetching: true;
750 error: undefined;
751 } & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
752 isSuccess: true;
753 isFetching: false;
754 error: undefined;
755 } & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
756 isError: true;
757 } & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'error'>>)>> & {
758 /**
759 * @deprecated Included for completeness, but discouraged.
760 * Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
761 * and `isUninitialized` flags instead
762 */
763 status: QueryStatus;
764 };
765 type MutationStateSelector<R extends Record<string, any>, D extends MutationDefinition<any, any, any, any>> = (state: MutationResultSelectorResult<D>) => R;
766 type UseMutationStateOptions<D extends MutationDefinition<any, any, any, any>, R extends Record<string, any>> = {
767 selectFromResult?: MutationStateSelector<R, D>;
768 fixedCacheKey?: string;
769 };
770 type UseMutationStateResult<D extends MutationDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R> & {
771 originalArgs?: QueryArgFrom<D>;
772 /**
773 * Resets the hook state to its initial `uninitialized` state.
774 * This will also remove the last result from the cache.
775 */
776 reset: () => void;
777 };
778 /**
779 * Helper type to manually type the result
780 * of the `useMutation` hook in userland code.
781 */
782 type TypedUseMutationResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = MutationResultSelectorResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseMutationStateResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
783 /**
784 * A React hook that lets you trigger an update request for a given endpoint, and subscribes the component to read the request status from the Redux store. The component will re-render as the loading status changes.
785 *
786 * #### Features
787 *
788 * - Manual control over firing a request to alter data on the server or possibly invalidate the cache
789 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
790 * - Returns the latest request status and cached data from the Redux store
791 * - Re-renders as the request status changes and data becomes available
792 */
793 type UseMutation<D extends MutationDefinition<any, any, any, any>> = <R extends Record<string, any> = MutationResultSelectorResult<D>>(options?: UseMutationStateOptions<D, R>) => readonly [MutationTrigger<D>, UseMutationStateResult<D, R>];
794 type TypedUseMutation<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseMutation<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
795 type MutationTrigger<D extends MutationDefinition<any, any, any, any>> = {
796 /**
797 * Triggers the mutation and returns a Promise.
798 * @remarks
799 * If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
800 *
801 * @example
802 * ```ts
803 * // codeblock-meta title="Using .unwrap with async await"
804 * try {
805 * const payload = await addPost({ id: 1, name: 'Example' }).unwrap();
806 * console.log('fulfilled', payload)
807 * } catch (error) {
808 * console.error('rejected', error);
809 * }
810 * ```
811 */
812 (arg: QueryArgFrom<D>): MutationActionCreatorResult<D>;
813 };
814 type TypedMutationTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = MutationTrigger<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
815
816 type QueryHookNames<Definitions extends EndpointDefinitions> = {
817 [K in keyof Definitions as Definitions[K] extends {
818 type: DefinitionType.query;
819 } ? `use${Capitalize<K & string>}Query` : never]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
820 };
821 type LazyQueryHookNames<Definitions extends EndpointDefinitions> = {
822 [K in keyof Definitions as Definitions[K] extends {
823 type: DefinitionType.query;
824 } ? `useLazy${Capitalize<K & string>}Query` : never]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
825 };
826 type InfiniteQueryHookNames<Definitions extends EndpointDefinitions> = {
827 [K in keyof Definitions as Definitions[K] extends {
828 type: DefinitionType.infinitequery;
829 } ? `use${Capitalize<K & string>}InfiniteQuery` : never]: UseInfiniteQuery<Extract<Definitions[K], InfiniteQueryDefinition<any, any, any, any, any>>>;
830 };
831 type MutationHookNames<Definitions extends EndpointDefinitions> = {
832 [K in keyof Definitions as Definitions[K] extends {
833 type: DefinitionType.mutation;
834 } ? `use${Capitalize<K & string>}Mutation` : never]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
835 };
836 type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = QueryHookNames<Definitions> & LazyQueryHookNames<Definitions> & InfiniteQueryHookNames<Definitions> & MutationHookNames<Definitions>;
837
838 export declare const reactHooksModuleName: unique symbol;
839 type ReactHooksModule = typeof reactHooksModuleName;
840 declare module '@reduxjs/toolkit/query' {
841 interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
842 [reactHooksModuleName]: {
843 /**
844 * Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.
845 */
846 endpoints: {
847 [K in keyof Definitions]: Definitions[K] extends QueryDefinition<any, any, any, any, any> ? QueryHooks<Definitions[K]> : Definitions[K] extends MutationDefinition<any, any, any, any, any> ? MutationHooks<Definitions[K]> : Definitions[K] extends InfiniteQueryDefinition<any, any, any, any, any> ? InfiniteQueryHooks<Definitions[K]> : never;
848 };
849 /**
850 * A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.
851 */
852 usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
853 } & HooksWithUniqueNames<Definitions>;
854 }
855 }
856 type RR = typeof react_redux;
857 interface ReactHooksModuleOptions {
858 /**
859 * The hooks from React Redux to be used
860 */
861 hooks?: {
862 /**
863 * The version of the `useDispatch` hook to be used
864 */
865 useDispatch: RR['useDispatch'];
866 /**
867 * The version of the `useSelector` hook to be used
868 */
869 useSelector: RR['useSelector'];
870 /**
871 * The version of the `useStore` hook to be used
872 */
873 useStore: RR['useStore'];
874 };
875 /**
876 * The version of the `batchedUpdates` function to be used
877 */
878 batch?: RR['batch'];
879 /**
880 * Enables performing asynchronous tasks immediately within a render.
881 *
882 * @example
883 *
884 * ```ts
885 * import {
886 * buildCreateApi,
887 * coreModule,
888 * reactHooksModule
889 * } from '@reduxjs/toolkit/query/react'
890 *
891 * const createApi = buildCreateApi(
892 * coreModule(),
893 * reactHooksModule({ unstable__sideEffectsInRender: true })
894 * )
895 * ```
896 */
897 unstable__sideEffectsInRender?: boolean;
898 /**
899 * A selector creator (usually from `reselect`, or matching the same signature)
900 */
901 createSelector?: typeof createSelector;
902 }
903 /**
904 * Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.
905 *
906 * @example
907 * ```ts
908 * const MyContext = React.createContext<ReactReduxContextValue | null>(null);
909 * const customCreateApi = buildCreateApi(
910 * coreModule(),
911 * reactHooksModule({
912 * hooks: {
913 * useDispatch: createDispatchHook(MyContext),
914 * useSelector: createSelectorHook(MyContext),
915 * useStore: createStoreHook(MyContext)
916 * }
917 * })
918 * );
919 * ```
920 *
921 * @returns A module for use with `buildCreateApi`
922 */
923 declare const reactHooksModule: ({ batch, hooks, createSelector, unstable__sideEffectsInRender, ...rest }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
924
925 /**
926 * Can be used as a `Provider` if you **do not already have a Redux store**.
927 *
928 * @example
929 * ```tsx
930 * // codeblock-meta no-transpile title="Basic usage - wrap your App with ApiProvider"
931 * import * as React from 'react';
932 * import { ApiProvider } from '@reduxjs/toolkit/query/react';
933 * import { Pokemon } from './features/Pokemon';
934 *
935 * function App() {
936 * return (
937 * <ApiProvider api={api}>
938 * <Pokemon />
939 * </ApiProvider>
940 * );
941 * }
942 * ```
943 *
944 * @remarks
945 * Using this together with an existing redux store, both will
946 * conflict with each other - please use the traditional redux setup
947 * in that case.
948 */
949 declare function ApiProvider(props: {
950 children: any;
951 api: Api<any, {}, any, any>;
952 setupListeners?: Parameters<typeof setupListeners>[1] | false;
953 context?: Context<ReactReduxContextValue | null>;
954 }): React.JSX.Element;
955
956 declare const createApi: _reduxjs_toolkit_query.CreateApi<typeof _reduxjs_toolkit_query.coreModuleName | typeof reactHooksModuleName>;
957
958 export { ApiProvider, type TypedInfiniteQueryStateSelector, type TypedLazyInfiniteQueryTrigger, type TypedLazyQueryTrigger, type TypedMutationTrigger, type TypedQueryStateSelector, type TypedUseInfiniteQuery, type TypedUseInfiniteQueryHookResult, type TypedUseInfiniteQueryState, type TypedUseInfiniteQueryStateOptions, type TypedUseInfiniteQueryStateResult, type TypedUseInfiniteQuerySubscription, type TypedUseInfiniteQuerySubscriptionResult, type TypedUseLazyQuery, type TypedUseLazyQueryStateResult, type TypedUseLazyQuerySubscription, type TypedUseMutation, type TypedUseMutationResult, type TypedUseQuery, type TypedUseQueryHookResult, type TypedUseQueryState, type TypedUseQueryStateOptions, type TypedUseQueryStateResult, type TypedUseQuerySubscription, type TypedUseQuerySubscriptionResult, createApi, reactHooksModule };