File tree Expand file tree Collapse file tree 1 file changed +30
-25
lines changed
packages/toolkit/src/query Expand file tree Collapse file tree 1 file changed +30
-25
lines changed Original file line number Diff line number Diff line change @@ -618,33 +618,38 @@ export interface InfiniteQueryExtraOptions<
618618 *
619619 * ```ts
620620 * // codeblock-meta title="infiniteQueryOptions example"
621- * getInfinitePokemonWithMax: build.infiniteQuery<
622- Pokemon[],
623- string,
624- number
625- >({
626- infiniteQueryOptions: {
627- initialPageParam: 0,
628- maxPages: 3,
629- getNextPageParam: (
630- lastPage,
631- allPages,
632- lastPageParam,
633- allPageParams,
634- ) => lastPageParam + 1,
635- getPreviousPageParam: (
636- firstPage,
637- allPages,
638- firstPageParam,
639- allPageParams,
640- ) => {
641- return firstPageParam > 0 ? firstPageParam - 1 : undefined
621+ * import { createApi, fetchBaseQuery, defaultSerializeQueryArgs } from '@reduxjs/toolkit/query/react'
622+ *
623+ * type Pokemon = {
624+ * id: string
625+ * name: string
626+ * }
627+ *
628+ const pokemonApi = createApi({
629+ baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
630+ endpoints: (build) => ({
631+ getInfinitePokemonWithMax: build.infiniteQuery<Pokemon[], string, number>({
632+ infiniteQueryOptions: {
633+ initialPageParam: 0,
634+ maxPages: 3,
635+ getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) =>
636+ lastPageParam + 1,
637+ getPreviousPageParam: (
638+ firstPage,
639+ allPages,
640+ firstPageParam,
641+ allPageParams,
642+ ) => {
643+ return firstPageParam > 0 ? firstPageParam - 1 : undefined
644+ },
645+ },
646+ query(pageParam) {
647+ return `https://example.com/listItems?page=${pageParam}`
642648 },
643- },
644- query(pageParam) {
645- return `https://example.com/listItems?page=${pageParam}`
646- },
649+ }),
647650 }),
651+ })
652+
648653 * ```
649654 */
650655 infiniteQueryOptions : InfiniteQueryConfigOptions < ResultType , PageParam >
You can’t perform that action at this time.
0 commit comments