Skip to content

fix(react-query): remove placeholderData from suspense infinite query - #11144

Open
RezaRahemtola wants to merge 1 commit into
TanStack:mainfrom
RezaRahemtola:fix/suspense-infinite-query-placeholder-data
Open

fix(react-query): remove placeholderData from suspense infinite query#11144
RezaRahemtola wants to merge 1 commit into
TanStack:mainfrom
RezaRahemtola:fix/suspense-infinite-query-placeholder-data

Conversation

@RezaRahemtola

@RezaRahemtola RezaRahemtola commented Aug 6, 2026

Copy link
Copy Markdown

🎯 Changes

useSuspenseInfiniteQuery doesn't override placeholderData from QueryClient defaults, so a global placeholderData config (e.g. (prev) => prev) causes the hook to render previous data instead of suspending on queryKey change.

PR #6973 fixed this for useSuspenseQuery and useSuspenseQueries but useSuspenseInfiniteQuery was missed. The result type already omits isPlaceholderData, confirming placeholder data should never appear in suspense results.

Also applied to preact-query (identical code, same bug) and added a regression test mirroring the sibling test from #6973.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Suspense infinite queries now ignore configured placeholder data, ensuring they suspend correctly while loading new results.
    • Updated behavior applies to both React and Preact query integrations.
  • Tests

    • Added coverage confirming loading states are shown again when the query key changes, even when placeholder data is configured.
  • Chores

    • Added patch release notes for the affected packages.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a4aa1fd9-f81f-4aea-9f5e-f6ebb6cb97e7

📥 Commits

Reviewing files that changed from the base of the PR and between 46d7f02 and 194f65d.

📒 Files selected for processing (4)
  • .changeset/useSuspenseInfiniteQuery-placeholderData.md
  • packages/preact-query/src/useSuspenseInfiniteQuery.ts
  • packages/react-query/src/__tests__/useSuspenseInfiniteQuery.test.tsx
  • packages/react-query/src/useSuspenseInfiniteQuery.ts

📝 Walkthrough

Walkthrough

The suspense infinite query hooks now disable placeholderData. React tests verify suspension after query key changes. A changeset records patch releases for the React and Preact Query packages.

Changes

Suspense infinite query behavior

Layer / File(s) Summary
Disable placeholder data in suspense hooks
packages/react-query/src/useSuspenseInfiniteQuery.ts, packages/preact-query/src/useSuspenseInfiniteQuery.ts
Both hooks pass placeholderData: undefined to useBaseQuery.
Validate behavior and record releases
packages/react-query/src/__tests__/useSuspenseInfiniteQuery.test.tsx, .changeset/useSuspenseInfiniteQuery-placeholderData.md
The test verifies suspension during query key changes. The changeset records patch releases for both packages.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing placeholderData from suspense infinite queries.
Description check ✅ Passed The description explains the problem, motivation, affected packages, test coverage, checklist, and changeset impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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