source: node_modules/@reduxjs/toolkit/dist/query/react/index.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 50.0 KB
Line 
1import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
2import { QueryDefinition, TSHelpersId, TSHelpersOverride, QuerySubState, ResultTypeFrom, QueryStatus, QueryArgFrom, SkipToken, SubscriptionOptions, TSHelpersNoInfer, QueryActionCreatorResult, MutationDefinition, MutationResultSelectorResult, MutationActionCreatorResult, InfiniteQueryDefinition, InfiniteQuerySubState, PageParamFrom, InfiniteQueryArgFrom, InfiniteQueryActionCreatorResult, BaseQueryFn, EndpointDefinitions, DefinitionType, QueryKeys, PrefetchOptions, Module, Api, setupListeners } from '@reduxjs/toolkit/query';
3export * from '@reduxjs/toolkit/query';
4import * as react_redux from 'react-redux';
5import { ReactReduxContextValue } from 'react-redux';
6import { CreateSelectorFunction } from 'reselect';
7import * as React from 'react';
8import { Context } from 'react';
9
10type InfiniteData<DataType, PageParam> = {
11 pages: Array<DataType>;
12 pageParams: Array<PageParam>;
13};
14type InfiniteQueryDirection = 'forward' | 'backward';
15
16export declare const UNINITIALIZED_VALUE: unique symbol;
17type UninitializedValue = typeof UNINITIALIZED_VALUE;
18
19type 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};
26type InfiniteQueryHooks<Definition extends InfiniteQueryDefinition<any, any, any, any, any>> = {
27 useInfiniteQuery: UseInfiniteQuery<Definition>;
28 useInfiniteQuerySubscription: UseInfiniteQuerySubscription<Definition>;
29 useInfiniteQueryState: UseInfiniteQueryState<Definition>;
30};
31type 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 */
49type 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>;
50type TypedUseQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
51type 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 */
56type TypedUseQueryHookResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery, R> & TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery>;
57type 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 */
114type UseQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (arg: QueryArgFrom<D> | SkipToken, options?: UseQuerySubscriptionOptions) => UseQuerySubscriptionResult<D>;
115type TypedUseQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
116type 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 */
121type TypedUseQuerySubscriptionResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQuerySubscriptionResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
122type 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 */
142type 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];
147type TypedUseLazyQuery<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuery<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
148type 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 */
159type TypedUseLazyQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseLazyQueryStateResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
160type 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};
183type 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 */
195type UseLazyQuerySubscription<D extends QueryDefinition<any, any, any, any>> = (options?: SubscriptionOptions) => readonly [
196 LazyQueryTrigger<D>,
197 QueryArgFrom<D> | UninitializedValue,
198 {
199 reset: () => void;
200 }
201];
202type TypedUseLazyQuerySubscription<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseLazyQuerySubscription<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
203/**
204 * @internal
205 */
206type 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 */
296type 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 */
307type 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>;
308type TypedUseQueryState<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseQueryState<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
309/**
310 * @internal
311 */
312type 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 */
439type 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>;
440type 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 */
445type TypedUseQueryStateResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = UseQueryStateDefaultResult<QueryDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = TSHelpersNoInfer<R>;
446type 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};
474type UseQueryStateUninitialized<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<Extract<UseQueryStateBaseResult<D>, {
475 status: QueryStatus.uninitialized;
476}>, {
477 isUninitialized: true;
478}>;
479type UseQueryStateLoading<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
480 isLoading: true;
481 isFetching: boolean;
482 data: undefined;
483}>;
484type UseQueryStateSuccessFetching<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
485 isSuccess: true;
486 isFetching: true;
487 error: undefined;
488} & {
489 data: ResultTypeFrom<D>;
490} & Required<Pick<UseQueryStateBaseResult<D>, 'fulfilledTimeStamp'>>>;
491type UseQueryStateSuccessNotFetching<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
492 isSuccess: true;
493 isFetching: false;
494 error: undefined;
495} & {
496 data: ResultTypeFrom<D>;
497 currentData: ResultTypeFrom<D>;
498} & Required<Pick<UseQueryStateBaseResult<D>, 'fulfilledTimeStamp'>>>;
499type UseQueryStateError<D extends QueryDefinition<any, any, any, any>> = TSHelpersOverride<UseQueryStateBaseResult<D>, {
500 isError: true;
501} & Required<Pick<UseQueryStateBaseResult<D>, 'error'>>>;
502type UseQueryStateDefaultResult<D extends QueryDefinition<any, any, any, any>> = TSHelpersId<UseQueryStateUninitialized<D> | UseQueryStateLoading<D> | UseQueryStateSuccessFetching<D> | UseQueryStateSuccessNotFetching<D> | UseQueryStateError<D>> & {
503 /**
504 * @deprecated Included for completeness, but discouraged.
505 * Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
506 * and `isUninitialized` flags instead
507 */
508 status: QueryStatus;
509};
510type LazyInfiniteQueryTrigger<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
511 /**
512 * Triggers a lazy query.
513 *
514 * By default, this will start a new request even if there is already a value in the cache.
515 * 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`.
516 *
517 * @remarks
518 * If you need to access the error or success payload immediately after a lazy query, you can chain .unwrap().
519 *
520 * @example
521 * ```ts
522 * // codeblock-meta title="Using .unwrap with async await"
523 * try {
524 * const payload = await getUserById(1).unwrap();
525 * console.log('fulfilled', payload)
526 * } catch (error) {
527 * console.error('rejected', error);
528 * }
529 * ```
530 */
531 (arg: QueryArgFrom<D>, direction: InfiniteQueryDirection): InfiniteQueryActionCreatorResult<D>;
532};
533type TypedLazyInfiniteQueryTrigger<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = LazyInfiniteQueryTrigger<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
534type UseInfiniteQuerySubscriptionOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>> = SubscriptionOptions & {
535 /**
536 * Prevents a query from automatically running.
537 *
538 * @remarks
539 * When `skip` is true (or `skipToken` is passed in as `arg`):
540 *
541 * - **If the query has cached data:**
542 * * 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
543 * * The query will have a status of `uninitialized`
544 * * If `skip: false` is set after the initial load, the cached result will be used
545 * - **If the query does not have cached data:**
546 * * The query will have a status of `uninitialized`
547 * * The query will not exist in the state when viewed with the dev tools
548 * * The query will not automatically fetch on mount
549 * * The query will not automatically run when additional components with the same query are added that do run
550 *
551 * @example
552 * ```tsx
553 * // codeblock-meta no-transpile title="Skip example"
554 * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
555 * const { data, error, status } = useGetPokemonByNameQuery(name, {
556 * skip,
557 * });
558 *
559 * return (
560 * <div>
561 * {name} - {status}
562 * </div>
563 * );
564 * };
565 * ```
566 */
567 skip?: boolean;
568 /**
569 * 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.
570 * - `false` - Will not cause a query to be performed _unless_ it does not exist yet.
571 * - `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.
572 * - `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.
573 *
574 * If you specify this option alongside `skip: true`, this **will not be evaluated** until `skip` is false.
575 */
576 refetchOnMountOrArgChange?: boolean | number;
577 initialPageParam?: PageParamFrom<D>;
578 /**
579 * Defaults to `true`. When this is `true` and an infinite query endpoint is refetched
580 * (due to tag invalidation, polling, arg change configuration, or manual refetching),
581 * RTK Query will try to sequentially refetch all pages currently in the cache.
582 * When `false` only the first page will be refetched.
583 *
584 * This option applies to all automatic refetches for this subscription (polling, tag invalidation, etc.).
585 * It can be overridden on a per-call basis using the `refetch()` method.
586 */
587 refetchCachedPages?: boolean;
588};
589type TypedUseInfiniteQuerySubscription<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscription<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
590type UseInfiniteQuerySubscriptionResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = {
591 refetch: (options?: Pick<UseInfiniteQuerySubscriptionOptions<D>, 'refetchCachedPages'>) => InfiniteQueryActionCreatorResult<D>;
592 trigger: LazyInfiniteQueryTrigger<D>;
593 fetchNextPage: () => InfiniteQueryActionCreatorResult<D>;
594 fetchPreviousPage: () => InfiniteQueryActionCreatorResult<D>;
595};
596/**
597 * Helper type to manually type the result
598 * of the `useQuerySubscription` hook in userland code.
599 */
600type TypedUseInfiniteQuerySubscriptionResult<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuerySubscriptionResult<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
601type InfiniteQueryStateSelector<R extends Record<string, any>, D extends InfiniteQueryDefinition<any, any, any, any, any>> = (state: UseInfiniteQueryStateDefaultResult<D>) => R;
602type 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>>;
603/**
604 * 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.
605 *
606 * 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.
607 *
608 * 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.
609 *
610 * This hook combines the functionality of both [`useInfiniteQueryState`](#useinfinitequerystate) and [`useInfiniteQuerySubscription`](#useinfinitequerysubscription) together, and is intended to be used in the majority of situations.
611 *
612 * As with normal query hooks, `skipToken` is a valid argument that will skip the query from executing.
613 *
614 * 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.
615 *
616 * 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.
617 *
618 *
619 * #### Features
620 *
621 * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
622 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
623 * - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
624 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
625 * - Returns the latest request status and cached data from the Redux store
626 * - Re-renders as the request status changes and data becomes available
627 */
628type 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'>;
629type TypedUseInfiniteQuery<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQuery<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
630/**
631 * 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.
632 *
633 * Note that this hook does not trigger fetching new data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQuerySubscription`](#useinfinitequerysubscription).
634 *
635 * #### Features
636 *
637 * - Returns the latest request status and cached data from the Redux store
638 * - Re-renders as the request status changes and data becomes available
639 */
640type 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>;
641type TypedUseInfiniteQueryState<ResultType, QueryArg, PageParam, BaseQuery extends BaseQueryFn> = UseInfiniteQueryState<InfiniteQueryDefinition<QueryArg, PageParam, BaseQuery, string, ResultType, string>>;
642/**
643 * 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.
644 *
645 * 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.
646 *
647 * Note that this hook does not return a request status or cached data. For that use-case, see [`useInfiniteQuery`](#useinfinitequery) or [`useInfiniteQueryState`](#useinfinitequerystate).
648 *
649 * #### Features
650 *
651 * - Automatically triggers requests to retrieve data based on the hook argument and whether cached data exists by default
652 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
653 * - Caches multiple pages worth of responses, and provides methods to trigger more page fetches forwards and backwards
654 * - Accepts polling/re-fetching options to trigger automatic re-fetches when the corresponding criteria is met
655 */
656type UseInfiniteQuerySubscription<D extends InfiniteQueryDefinition<any, any, any, any, any>> = (arg: InfiniteQueryArgFrom<D> | SkipToken, options?: UseInfiniteQuerySubscriptionOptions<D>) => UseInfiniteQuerySubscriptionResult<D>;
657type UseInfiniteQueryHookResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = UseInfiniteQueryStateResult<D, R> & Pick<UseInfiniteQuerySubscriptionResult<D>, 'refetch' | 'fetchNextPage' | 'fetchPreviousPage'>;
658type 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>;
659type UseInfiniteQueryStateOptions<D extends InfiniteQueryDefinition<any, any, any, any, any>, R extends Record<string, any>> = {
660 /**
661 * Prevents a query from automatically running.
662 *
663 * @remarks
664 * When skip is true:
665 *
666 * - **If the query has cached data:**
667 * * 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
668 * * The query will have a status of `uninitialized`
669 * * If `skip: false` is set after skipping the initial load, the cached result will be used
670 * - **If the query does not have cached data:**
671 * * The query will have a status of `uninitialized`
672 * * The query will not exist in the state when viewed with the dev tools
673 * * The query will not automatically fetch on mount
674 * * The query will not automatically run when additional components with the same query are added that do run
675 *
676 * @example
677 * ```ts
678 * // codeblock-meta title="Skip example"
679 * const Pokemon = ({ name, skip }: { name: string; skip: boolean }) => {
680 * const { data, error, status } = useGetPokemonByNameQuery(name, {
681 * skip,
682 * });
683 *
684 * return (
685 * <div>
686 * {name} - {status}
687 * </div>
688 * );
689 * };
690 * ```
691 */
692 skip?: boolean;
693 /**
694 * `selectFromResult` allows you to get a specific segment from a query result in a performant manner.
695 * When using this feature, the component will not rerender unless the underlying data of the selected item has changed.
696 * If the selected item is one element in a larger collection, it will disregard changes to elements in the same collection.
697 * Note that this should always return an object (not a primitive), as RTKQ adds fields to the return value.
698 *
699 * @example
700 * ```ts
701 * // codeblock-meta title="Using selectFromResult to extract a single result"
702 * function PostsList() {
703 * const { data: posts } = api.useGetPostsQuery();
704 *
705 * return (
706 * <ul>
707 * {posts?.data?.map((post) => (
708 * <PostById key={post.id} id={post.id} />
709 * ))}
710 * </ul>
711 * );
712 * }
713 *
714 * function PostById({ id }: { id: number }) {
715 * // Will select the post with the given id, and will only rerender if the given posts data changes
716 * const { post } = api.useGetPostsQuery(undefined, {
717 * selectFromResult: ({ data }) => ({ post: data?.find((post) => post.id === id) }),
718 * });
719 *
720 * return <li>{post?.name}</li>;
721 * }
722 * ```
723 */
724 selectFromResult?: InfiniteQueryStateSelector<R, D>;
725};
726type 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>;
727type UseInfiniteQueryStateResult<D extends InfiniteQueryDefinition<any, any, any, any, any>, R = UseInfiniteQueryStateDefaultResult<D>> = TSHelpersNoInfer<R>;
728type 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>;
729type UseInfiniteQueryStateBaseResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = InfiniteQuerySubState<D> & {
730 /**
731 * Where `data` tries to hold data as much as possible, also re-using
732 * data from the last arguments passed into the hook, this property
733 * will always contain the received data from the query, for the current query arguments.
734 */
735 currentData?: InfiniteData<ResultTypeFrom<D>, PageParamFrom<D>>;
736 /**
737 * Query has not started yet.
738 */
739 isUninitialized: false;
740 /**
741 * Query is currently loading for the first time. No data yet.
742 */
743 isLoading: false;
744 /**
745 * Query is currently fetching, but might have data from an earlier request.
746 */
747 isFetching: false;
748 /**
749 * Query has data from a successful load.
750 */
751 isSuccess: false;
752 /**
753 * Query is currently in "error" state.
754 */
755 isError: false;
756 hasNextPage: boolean;
757 hasPreviousPage: boolean;
758 isFetchingNextPage: boolean;
759 isFetchingPreviousPage: boolean;
760};
761type UseInfiniteQueryStateDefaultResult<D extends InfiniteQueryDefinition<any, any, any, any, any>> = TSHelpersId<TSHelpersOverride<Extract<UseInfiniteQueryStateBaseResult<D>, {
762 status: QueryStatus.uninitialized;
763}>, {
764 isUninitialized: true;
765}> | TSHelpersOverride<UseInfiniteQueryStateBaseResult<D>, {
766 isLoading: true;
767 isFetching: boolean;
768 data: undefined;
769} | ({
770 isSuccess: true;
771 isFetching: true;
772 error: undefined;
773} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp'>>) | ({
774 isSuccess: true;
775 isFetching: false;
776 error: undefined;
777} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'data' | 'fulfilledTimeStamp' | 'currentData'>>) | ({
778 isError: true;
779} & Required<Pick<UseInfiniteQueryStateBaseResult<D>, 'error'>>)>> & {
780 /**
781 * @deprecated Included for completeness, but discouraged.
782 * Please use the `isLoading`, `isFetching`, `isSuccess`, `isError`
783 * and `isUninitialized` flags instead
784 */
785 status: QueryStatus;
786};
787type MutationStateSelector<R extends Record<string, any>, D extends MutationDefinition<any, any, any, any>> = (state: MutationResultSelectorResult<D>) => R;
788type UseMutationStateOptions<D extends MutationDefinition<any, any, any, any>, R extends Record<string, any>> = {
789 selectFromResult?: MutationStateSelector<R, D>;
790 fixedCacheKey?: string;
791};
792type UseMutationStateResult<D extends MutationDefinition<any, any, any, any>, R> = TSHelpersNoInfer<R> & {
793 originalArgs?: QueryArgFrom<D>;
794 /**
795 * Resets the hook state to its initial `uninitialized` state.
796 * This will also remove the last result from the cache.
797 */
798 reset: () => void;
799};
800/**
801 * Helper type to manually type the result
802 * of the `useMutation` hook in userland code.
803 */
804type TypedUseMutationResult<ResultType, QueryArg, BaseQuery extends BaseQueryFn, R = MutationResultSelectorResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>> = UseMutationStateResult<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>, R>;
805/**
806 * 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.
807 *
808 * #### Features
809 *
810 * - Manual control over firing a request to alter data on the server or possibly invalidate the cache
811 * - 'Subscribes' the component to keep cached data in the store, and 'unsubscribes' when the component unmounts
812 * - Returns the latest request status and cached data from the Redux store
813 * - Re-renders as the request status changes and data becomes available
814 */
815type 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>];
816type TypedUseMutation<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = UseMutation<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
817type MutationTrigger<D extends MutationDefinition<any, any, any, any>> = {
818 /**
819 * Triggers the mutation and returns a Promise.
820 * @remarks
821 * If you need to access the error or success payload immediately after a mutation, you can chain .unwrap().
822 *
823 * @example
824 * ```ts
825 * // codeblock-meta title="Using .unwrap with async await"
826 * try {
827 * const payload = await addPost({ id: 1, name: 'Example' }).unwrap();
828 * console.log('fulfilled', payload)
829 * } catch (error) {
830 * console.error('rejected', error);
831 * }
832 * ```
833 */
834 (arg: QueryArgFrom<D>): MutationActionCreatorResult<D>;
835};
836type TypedMutationTrigger<ResultType, QueryArg, BaseQuery extends BaseQueryFn> = MutationTrigger<MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>>;
837
838type QueryHookNames<Definitions extends EndpointDefinitions> = {
839 [K in keyof Definitions as Definitions[K] extends {
840 type: DefinitionType.query;
841 } ? `use${Capitalize<K & string>}Query` : never]: UseQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
842};
843type LazyQueryHookNames<Definitions extends EndpointDefinitions> = {
844 [K in keyof Definitions as Definitions[K] extends {
845 type: DefinitionType.query;
846 } ? `useLazy${Capitalize<K & string>}Query` : never]: UseLazyQuery<Extract<Definitions[K], QueryDefinition<any, any, any, any>>>;
847};
848type InfiniteQueryHookNames<Definitions extends EndpointDefinitions> = {
849 [K in keyof Definitions as Definitions[K] extends {
850 type: DefinitionType.infinitequery;
851 } ? `use${Capitalize<K & string>}InfiniteQuery` : never]: UseInfiniteQuery<Extract<Definitions[K], InfiniteQueryDefinition<any, any, any, any, any>>>;
852};
853type MutationHookNames<Definitions extends EndpointDefinitions> = {
854 [K in keyof Definitions as Definitions[K] extends {
855 type: DefinitionType.mutation;
856 } ? `use${Capitalize<K & string>}Mutation` : never]: UseMutation<Extract<Definitions[K], MutationDefinition<any, any, any, any>>>;
857};
858type HooksWithUniqueNames<Definitions extends EndpointDefinitions> = QueryHookNames<Definitions> & LazyQueryHookNames<Definitions> & InfiniteQueryHookNames<Definitions> & MutationHookNames<Definitions>;
859
860export declare const reactHooksModuleName: unique symbol;
861type ReactHooksModule = typeof reactHooksModuleName;
862declare module '@reduxjs/toolkit/query' {
863 interface ApiModules<BaseQuery extends BaseQueryFn, Definitions extends EndpointDefinitions, ReducerPath extends string, TagTypes extends string> {
864 [reactHooksModuleName]: {
865 /**
866 * Endpoints based on the input endpoints provided to `createApi`, containing `select`, `hooks` and `action matchers`.
867 */
868 endpoints: {
869 [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;
870 };
871 /**
872 * A hook that accepts a string endpoint name, and provides a callback that when called, pre-fetches the data for that endpoint.
873 */
874 usePrefetch<EndpointName extends QueryKeys<Definitions>>(endpointName: EndpointName, options?: PrefetchOptions): (arg: QueryArgFrom<Definitions[EndpointName]>, options?: PrefetchOptions) => void;
875 } & HooksWithUniqueNames<Definitions>;
876 }
877}
878type RR = typeof react_redux;
879interface ReactHooksModuleOptions {
880 /**
881 * The hooks from React Redux to be used
882 */
883 hooks?: {
884 /**
885 * The version of the `useDispatch` hook to be used
886 */
887 useDispatch: RR['useDispatch'];
888 /**
889 * The version of the `useSelector` hook to be used
890 */
891 useSelector: RR['useSelector'];
892 /**
893 * The version of the `useStore` hook to be used
894 */
895 useStore: RR['useStore'];
896 };
897 /**
898 * The version of the `batchedUpdates` function to be used
899 */
900 batch?: RR['batch'];
901 /**
902 * Enables performing asynchronous tasks immediately within a render.
903 *
904 * @example
905 *
906 * ```ts
907 * import {
908 * buildCreateApi,
909 * coreModule,
910 * reactHooksModule
911 * } from '@reduxjs/toolkit/query/react'
912 *
913 * const createApi = buildCreateApi(
914 * coreModule(),
915 * reactHooksModule({ unstable__sideEffectsInRender: true })
916 * )
917 * ```
918 */
919 unstable__sideEffectsInRender?: boolean;
920 /**
921 * A selector creator (usually from `reselect`, or matching the same signature)
922 */
923 createSelector?: CreateSelectorFunction<any, any, any>;
924}
925/**
926 * Creates a module that generates react hooks from endpoints, for use with `buildCreateApi`.
927 *
928 * @example
929 * ```ts
930 * const MyContext = React.createContext<ReactReduxContextValue | null>(null);
931 * const customCreateApi = buildCreateApi(
932 * coreModule(),
933 * reactHooksModule({
934 * hooks: {
935 * useDispatch: createDispatchHook(MyContext),
936 * useSelector: createSelectorHook(MyContext),
937 * useStore: createStoreHook(MyContext)
938 * }
939 * })
940 * );
941 * ```
942 *
943 * @returns A module for use with `buildCreateApi`
944 */
945declare const reactHooksModule: ({ batch, hooks, createSelector, unstable__sideEffectsInRender, ...rest }?: ReactHooksModuleOptions) => Module<ReactHooksModule>;
946
947/**
948 * Can be used as a `Provider` if you **do not already have a Redux store**.
949 *
950 * @example
951 * ```tsx
952 * // codeblock-meta no-transpile title="Basic usage - wrap your App with ApiProvider"
953 * import * as React from 'react';
954 * import { ApiProvider } from '@reduxjs/toolkit/query/react';
955 * import { Pokemon } from './features/Pokemon';
956 *
957 * function App() {
958 * return (
959 * <ApiProvider api={api}>
960 * <Pokemon />
961 * </ApiProvider>
962 * );
963 * }
964 * ```
965 *
966 * @remarks
967 * Using this together with an existing redux store, both will
968 * conflict with each other - please use the traditional redux setup
969 * in that case.
970 */
971declare function ApiProvider(props: {
972 children: any;
973 api: Api<any, {}, any, any>;
974 setupListeners?: Parameters<typeof setupListeners>[1] | false;
975 context?: Context<ReactReduxContextValue | null>;
976}): React.JSX.Element;
977
978declare const createApi: _reduxjs_toolkit_query.CreateApi<typeof _reduxjs_toolkit_query.coreModuleName | typeof reactHooksModuleName>;
979
980export { 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 };
Note: See TracBrowser for help on using the repository browser.