docs(solid-query): fix incorrect Vue.js code example in Suspense guide #9813
main fromrefs/pull/9813/head·merged by TkDodo View on GitHubReplace Vue.js code example with proper SolidJS syntax in the Suspense documentation. The example was using Vue's defineComponent and setup() instead of SolidJS patterns.
Fixes issue with non-existent useSuspenseQuery examples in Solid Query docs.
🎯 Changes#
✅ 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#
- Documentation
- Updated Suspense guide to replace the Vue-based example with a SolidJS functional-component example.
- Code samples switched to TSX and demonstrate using the query hook pattern to access data inside a Suspense boundary.
- Removed prior suspense control-flow example and clarified relying on Suspense boundaries for suspension behavior.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation
Walkthrough#
Replaces a Vue Suspense example with a SolidJS functional component that uses useQuery and JSX, removing Vue's setup/suspense pattern and relying on a Suspense boundary to suspend until query.data is available.
Changes#
Cohort / File(s) Summary SolidJS Suspense Documentation
docs/framework/solid/guides/suspense.mdReplace Vue SFC example (defineComponent/setup/suspense) with a SolidJS TSX functional component using useQueryand JSX. Remove explicitsuspense()awaiting; rely on Suspense boundary and renderquery.datadirectly. Update code block language to TSX and adjust imports.Sequence Diagram(s)#
sequenceDiagram participant Suspense as Suspense Boundary participant Component as SolidJS Component participant Query as useQuery Hook Component->>Query: call useQuery(queryKey, queryFn) Query-->>Component: return query object (status, data, promise) Component->>Suspense: attempt to read query.data during render Suspense->>Query: if not ready, wait on query promise Query-->>Suspense: resolve promise when data ready Suspense-->>Component: allow render to continue Component->>Component: render JSX with query.dataEstimated code review effort#
🎯 2 (Simple) | ⏱️ ~10 minutes
- Check
useQueryimport and API usage matches @tanstack/solid-query version. - Verify the TSX example compiles (props/JSX types) and that Suspense boundary behavior is correctly described.
- Confirm code block language and inline comments reflect SolidJS patterns.
Poem#
🐇 I hopped from Vue leaves to Solid ground,
Suspense now waits where hooks are found, query.data blooms when promises cease, Docs now whisper a reactive peace, 🥕✨ — a rabbit's small release
Pre-merge checks and finishing touches#
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstringsto improve docstring coverage.Description Check ⚠️ Warning The pull request includes an introductory description that clearly explains the change (replacing Vue code with SolidJS in the Suspense documentation) and its motivation. However, the description does not properly follow the required template structure. The "## 🎯 Changes" section, which is a required component, is empty and only contains the placeholder comment rather than filled-in content describing the changes and motivation. Additionally, the checklist items in the "## ✅ Checklist" section are unchecked, suggesting the author has not confirmed following the contributing guide or completing local testing. The "## 🚀 Release Impact" section is correctly marked as docs/CI/dev-only, which is appropriate for documentation changes. The "## 🎯 Changes" section should be filled in with the actual change description (the information currently in the intro can be moved here). The checklist items should be checked if the author has followed the contributing guide and tested locally, or clarified if they have not. Once these sections are properly completed according to the template structure, the description will meet the requirements. ✅ Passed checks (1 passed)
Check name Status Explanation Title Check ✅ Passed The pull request title "docs(solid-query): fix incorrect Vue.js code example in Suspense guide" is fully related to the changeset. According to the raw summary, the PR replaces a Vue-based Suspense example (using defineComponent and setup) with proper SolidJS functional component syntax in the documentation file. The title clearly and specifically describes this main change without vague terminology or unnecessary detail. The conventional "docs(scope): description" format makes it scannable and professional. ✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
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 `@coderabbitai help` to get the list of available commands and usage tips.- Check
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 38b40081cedd207285ac0b4bb6818a2e84704b95 and 09141645bb4f0e4b5bfc77ffc0ed7395f2b341a7.
📒 Files selected for processing (1)
docs/framework/solid/guides/suspense.md(1 hunks)
@@ -33,6 +27,16 @@33-34- return { data }35- },36-})37-</script>27+28+function SuspendableComponent() {29+ const query = useQuery(() => ({30+ queryKey: ['todos'],31+ queryFn: todoFetcher,32+ }))33+34+ createEffect(async () => {35+ if (query.suspense) {36+ await query.suspense()37+ }38+ })39+40+ return <div>Data: {JSON.stringify(query.data)}</div>41+}3842 ```⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
Verify the suspense pattern matches Solid Query best practices.
The code example looks syntactically correct for SolidJS, and properly demonstrates using
useQuery()with a reactive function wrapper and accessing thesuspense()function. However, I want to confirm one aspect: in SolidJS,createEffectruns after initial component render, whereas suspense typically needs to throw a promise during render to trigger the parent Suspense boundary.The current pattern of awaiting
query.suspense()in acreateEffectmay work with Solid Query's implementation, but it's worth verifying this matches Solid Query's documented best practices and examples.
🌐 Web query:
What is the recommended pattern for using Suspense with Solid Query?💡 Result:
Recommended pattern — concise summary:
- Wrap suspendable UI in Solid's and an . Access the query.data only inside that Suspense so it can trigger the boundary while fetching. [1][2][4]
- Use useQuery (or useSuspenseQuery) with suspense enabled (or rely on the default behavior) and optionally throwOnError to let ErrorBoundary catch errors. The query's data is a Solid resource so reading it inside Suspense suspends until ready. [1][2][4]
- For "render-as-you-fetch" (start loads before mounting), prefetch on route callbacks or user events (queryClient.prefetchQuery or usePrefetchQuery) and keep the actual Suspense-bound query in the component. This avoids blocking parent renders. [3]
Key references:
- useQuery / Suspense behavior and throwOnError. [1]
- Suspense guide + fetch-on-render vs render-as-you-fetch. [2]
- Prefetching / router integration examples. [3]
- Quick-start Suspense examples. [4]
References: [1] TanStack Query Solid — useQuery (docs). [2] TanStack Query Solid — Suspense guide. [3] TanStack Query Solid — Prefetching & Router Integration. [4] TanStack Query Solid — Quick Start.
Remove the unnecessary
createEffectand rely on directquery.dataaccess within a Suspense boundary.According to TanStack Query Solid documentation, the recommended pattern is to access
query.datadirectly inside a<Suspense>boundary during render, which automatically triggers suspension. The query's data is a Solid resource so reading it inside Suspense suspends until ready.The
createEffectpattern in lines 34–38 is unnecessary and non-idiomatic. Post-render effects don't properly integrate with SolidJS's Suspense mechanism. Remove the effect entirely; the component should simply readquery.dataduring render while wrapped in a parent<Suspense>boundary.🤖 Prompt for AI Agents
In docs/framework/solid/guides/suspense.md around lines 19 to 42, the component uses an unnecessary createEffect to await query.suspense(), which is non-idiomatic and prevents proper Suspense integration; remove the createEffect block (lines 34–38) and instead rely on directly reading query.data during render while ensuring the component is used inside a parent <Suspense> boundary so Solid will suspend automatically until the data is ready.✅ Addressed in commit 4b5170e
TkDodo merged this878782b
TkDodo closed this
Sign in to join this conversation.
⚠️ No Changeset found#
Latest commit: 4b5170eafe722bae5c651e8955b3bd30725684ae
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR