How to add custom data/config/state to a request? #2545
Unanswered
ACoolmanBigHealth
asked this question in
Q&A
Replies: 1 comment
-
I think using the queryKey is an okay approach because |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
ℹ️ Code below is basically pseudocode, as I'm only vaguely familiar with API
Problem
We would like to show a global loader for some requests, and not for others.
Ideally, we would like to decide at the invocation of the request
Then later we can somehow determin if anything that was marked as "show loader"
Conceptually, we are adding more UI state to the request config
Option 1: add information to the
queryKey
We could add
isHideLoader
"param" to queryKey (which is scrubbed byqueryKeyHashFn
)So later we could do
This seems elegant, but perhaps there is some fragility I'm missing
Question: Is this "overloading" the concept of queryKeys in a non-idiomatic way?
Option 2: Maintain new state, using
onSettled
Or alternatively, we could wrap
useQuery
and use its handlersQuestion: Is either of these the "best"? or is there some other option I'm missing?
Beta Was this translation helpful? Give feedback.
All reactions