Skip to content

skipToken is passed into my infiniteQuery as a queryArg #5028

Open
@markerikson

Description

@markerikson

Discussed in #5027

Originally posted by soggybeef July 4, 2025
Language: Typescript
Version: "@reduxjs/toolkit": "^2.3.0",

I was trying to conditionally run an infinite query to prevent the first request from being made upon mounting of the component. The args will be taken from router which is from next/router

I have the args for queryArg as shouldSkip ? skipToken : args. But when shouldSkip === true and skipToken is passed in, the first request is still being made, and this is what i got from my console logs when forming the query in the services page where the endpoint is defined:

image

Since the logic of forming my queryParams doesn't and shouldn't take into account the skipToken, the request is still being sent in to fetch data that i don't want to fetch. This data is returned, but not returned or populated to my parent component. But I see it under the Responses in my Network Requests.

image

Would love any tips and corrections on how I can better handle the skipToken in my infiniteQuery, thank you!

EDIT: I see similar behavior when using skip: shouldSkip as part of the second argument in my useInfiniteQuery; the original args that I had became the queryArgs and the request is sent and returned, but not poulated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions