-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
docs(react-query): add caveat for typing getQueriesData #9684
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
WalkthroughClarifies in the React TypeScript docs that type inference from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous 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. Comment |
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.
|
View your CI Pipeline Execution ↗ for commit 6fb352b
☁️ Nx Cloud last updated this comment at |
🎯 Changes
The docs explain how to use
queryOptionsto get nice type inference on queries. It explicitly calls out how the type gets attached to thequeryKey, so that evenqueryClient.getQueryData()(which just accepts thequeryKeyand not the full options with thequeryFncan infer the type of the returned data.I was surprised to discover that this does not work for the plural equivalent
queryClient.getQueriesData(). I went to open a bug, and found #8613, which directed me to the docs for this method, which do explain why this does not work.I think it would be good to add the same caveat to the section of the docs where the trick is explained. That's what this PR does. The intention is for the docs to say "here's how to do it, here's a special bonus where you might not think it works but does, and here's a different special case where it does not work".
✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit