-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Suspense example in docs is incorrect #9019
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
Comments
Hi @mpiroc, thanks for the clear issue and solution. I noticed this hasn't been updated for a few weeks. |
@xxziiko Go for it! |
@mpiroc Thanks! I'll get started on a PR for this and will link it here once it's ready. |
xxziiko
added a commit
to xxziiko/query
that referenced
this issue
May 7, 2025
The previous suspense example incorrectly rendered null instead of the fallback UI. This change moves the null check outside the Suspense component to ensure the fallback is displayed as expected. Fixes TanStack#9019
This was referenced May 8, 2025
fix PR: #9119 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
A user on discord noticed that the fallback never renders for this example: https://tanstack.com/query/latest/docs/framework/react/examples/suspense
I believe this example is wrong. On the initial render,
React.Suspsense
's content successfully renders, it just rendersnull
. So whenProject
orProjects
suspend, react continues displaying the most recent successful render (null
) until data has been fetched.To fix this, move the
null
case outside of theReact.Suspense
component:Your minimal, reproducible example
Original example:
https://tanstack.com/query/latest/docs/framework/react/examples/suspense?panel=sandbox
Fixed example:
https://stackblitz.com/edit/tanstack-query-4yma8xjz?file=src%2Findex.tsx
Steps to reproduce
Expected: The fallback (
Loading projects...
) is rendered while the query is loadingActual:
null
is rendered while the query is loading.Expected behavior
As a developer, I expected the fallback (
Loading projects...
) to render. Instead, nothing (null
) was rendered.How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
OS: MacOS
Browser: Chrome
Browser Version: 135.0.7049.85
Tanstack Query adapter
react-query
TanStack Query version
v5.74.3
TypeScript version
5.8.3
Additional context
No response
The text was updated successfully, but these errors were encountered: