Replies: 1 comment 3 replies
-
key and meta are part of the query input, not the output. For your use-case, I’d suggest placeholderData. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I found the meta option on useQuery options. I thought this would be a great place to store the text I want to show the user while a query is loading.
Previously, I had a hook where I pass in an array of queries and their names. Something like:
const queryStatus = useQueryStatus({queries, queryNames})
Where queryStatus would either show an error, s loading spinner, or null if the data returned successfully.
I thought I could move the name into meta, which would remove the need to pass it in as a separate prop. The documentation says, "It will be accessible wherever the query is available". meta is shown in the devtools, but I am unable to access it on the return value from useQuery. I thought maybe I could pull meta out of the query cache, but the query key is also not available in UseQueryResult.
This makes me wonder. Is there a way to get the key or meta from the query result? Maybe I am thinking about this the wrong way. Is there a better way to pass data with the query result, or do I need a separate object?
Beta Was this translation helpful? Give feedback.
All reactions