Skip to content

Conversation

@rossmartin
Copy link
Contributor

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

@codesandbox
Copy link

codesandbox bot commented Jun 18, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 18, 2025

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 81715b2:

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

@netlify
Copy link

netlify bot commented Jun 18, 2025

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

Name Link
🔨 Latest commit 81715b2
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/69238d6bfb3b4000086ec72c
😎 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.

@JacobJaffe
Copy link

Any update on this PR? This behavior is super helpful-- I've been patching this onto my projects (and can continue to, but it's tedious to build a new patch for each rtk version update), and refreshing has been working great with it.

@markerikson
Copy link
Collaborator

I'll try to find some time to review it in the next few days. Good to know that A) it's useful, and B) the approach appears to be working - thanks for that feedback!

@markerikson markerikson force-pushed the master branch 2 times, most recently from 896b35d to 8d46313 Compare November 23, 2025 22:27
@markerikson markerikson merged commit c13e494 into reduxjs:master Nov 23, 2025
63 checks passed
@markerikson
Copy link
Collaborator

Out in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.11.0 ! Thanks!

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.

3 participants