-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Pass though queryKey on useQuery #62
Comments
What is your use case?
Tanner Linsley
…On Dec 5, 2019, 2:16 PM -0500, Jim Cummins ***@***.***>, wrote:
Hi @tannerlinsley,
One thing that would be nice is to return the queryKey on the object returned from the useQuery hook.
Would you consider this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Please reopen with a use case and we can discuss more :) |
Hey sorry, been running around a bit. Anyhow, the use case is for someone who is creating a redistributable subey'ed queries in redistributable custom hooks. We want to return the final key so that it can be used for refetching. It is totally an optimization, pure and simple: this works: // definition
function useMyCustomHook (subkey) {
const queryKey="apple" + subkey;
return {
queryKey,
...useQuery(queryKey);
}
// usage
const { queryKey } = useMyCustomHook('banana') but this would be preferable: // definition
function useMyCustomHook (subkey) {
return useQuery('apple'+subkey)
}
// usage
const { queryKey } = useMyCustomHook('banana') Cheers. |
@tannerlinsley Looks like I could open a new issue or you can open this one, whatever you prefer. Didn't want to dupe the issues board if you decide this isn't something you'd want. |
Hi @tannerlinsley,
One thing that would be nice is to return the queryKey on the object returned from the useQuery hook.
Would you consider this?
The text was updated successfully, but these errors were encountered: