-
-
Notifications
You must be signed in to change notification settings - Fork 38
doc: add computed tip for vue query #446
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughA new tip section was introduced in the documentation for Tanstack Query usage with Vue. This section provides guidance on handling non-constant query parameters by wrapping them in a Vue Changes
Sequence Diagram(s)📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/reference/plugins/tanstack-query.mdx (1)
425-426: Refine tip wording and clarity
The sentence “wrap the query in acomputed” could be more precise. Consider specifying that it’s the query arguments or parameters that need to be wrapped in a reactive computed property. For example:If your query parameters aren’t constant, wrap the parameters in a
computedproperty to ensure the query stays reactive.
| ```ts | ||
| const queryParams = computed(() => ({ | ||
| where: { | ||
| space: { slug: route.params.slug as string }, | ||
| id: meQuery.data.value?.userId | ||
| }, | ||
| })); | ||
| const { data: posts } = useFindManyPost(queryParams); | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add missing imports and context in the example
The snippet references computed, route, and meQuery without showing how they’re imported or initialized, which may confuse readers. You could update the snippet to include necessary imports and a mock user‑query hook. For example:
```ts
+import { computed } from 'vue';
+import { useRoute } from 'vue-router';
+import { useGetCurrentUser } from '@/lib/hooks'; // adjust hook name as needed
+
+const route = useRoute();
+const userQuery = useGetCurrentUser();
-const queryParams = computed(() => ({
+const queryParams = computed(() => ({
where: {
space: { slug: route.params.slug as string },
- id: meQuery.data.value?.userId
+ id: userQuery.data?.id
},
}));
const { data: posts } = useFindManyPost(queryParams);This makes the example self‑contained and runnable.
Summary by CodeRabbit
computedproperties for reactive query parameters.