-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: don't update dataUpdateCount when setting initial data #9743
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: ad5d0ba The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis PR adjusts Query’s success-state handling to avoid incrementing dataUpdateCount when initialData is set manually at mount. It adds a targeted test verifying isFetchedAfterMount and dataUpdateCount behavior with initialData and subsequent refetch, and includes a changeset marking a patch for @tanstack/react-query. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor UI as Component
participant Obs as QueryObserver
participant QC as QueryClient
participant Q as Query
UI->>Obs: Mount with initialData
Obs->>QC: Subscribe to query key
QC->>Q: Create/attach observer
Note right of Q: Apply initialData as manual<br/>(no dataUpdateCount increment,<br/>isFetchedAfterMount=false)
UI->>Obs: Trigger refetch
Obs->>Q: fetch()
Q->>Q: Resolve to fetched data
Note right of Q: Update data, increment dataUpdateCount,<br/>isFetchedAfterMount=true
Q-->>Obs: Notify result
Obs-->>UI: Render with fetched data
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎯 Changes
This introduces a check when updating
dataUpdateCount
so that it isn't updated when setting initial data. This in turn fixes theisFetchedAfterMount
bug discussed in #9656fixes #9656
✅ Checklist
pnpm test:pr
🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests
Chores