dataguttD
tRPC11mo ago
9 replies
datagutt

skipToken combined with the new tanstack query options

I am trying to prefetch the next x pages in a table, but i have some logic to determine whether or not this should happen.
I used to use skipToken for this, with the old tanstack query package, and it seemed to sort of working.

I tried changing the code to fit the new react query package, but it instead of skipping it now runs the API call without any options.


 usePrefetchQuery(
    trpc.lead.paginate.queryOptions(
      query?.data?.pagination &&
        query.data.pagination.page > 1 &&
        query.data.pagination.page < query.data.pagination.totalPages
        ? {
            ...input,
            pagination: { perPage: paginationOptions.perPage, page: query.data.pagination.page - 1 },
          }
        : skipToken,
    ),
  );
Was this page helpful?