Skip to content

Add refetchCachedPages option for infinite query #5016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rossmartin
Copy link

This refetchCachedPages option allows an infinite query to NOT refetch all pages in the cache when a refetch happens. By default it is true and uses the existing behavior.

This is based on what was mentioned in the discussion here - #5011. It's also based on this resolved issue here - #4920

We want the ability to opt out of this behavior at this level. We don't want to have to reset the pages/pageParams for a query when args change or during a refetch.

Here is an example of how it can be used:

    getPosts: builder.infiniteQuery<GetPostsResponse, GetPostsRequest, string | undefined>({
      infiniteQueryOptions: {
        // ...
        refetchCachedPages: false,
      },
      // ...
    }),  
Screenshot 2025-06-18 at 5 03 08 PM

Copy link

codesandbox bot commented Jun 18, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 13d7927:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

netlify bot commented Jun 18, 2025

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 13d7927
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/68533a4ff189830008dc10fd
😎 Deploy Preview https://deploy-preview-5016--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant