Query key unstable - API suggest value #8646
Unanswered
Lilja-at-funnel
asked this question in
Q&A
Replies: 1 comment 2 replies
-
why does a query have a delimiter as part of the key when its job is to determine that delimiter? Also, why do you need to “copy” the data into local state? I think it should just be:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Struggling to come up with a good title. Also, this might be discussed elsewhere. Could not find anything on github.
Imagine if you had a service that would give you file configuration guesses on CSV files you sent to it. You don't know the delimiter, so you need the service to guess the delimiter used(, or ; in this case)
React code on the client.
Because we use react's useState, the query key for the delimiter will change and subsequently fire a request to the API. In this case, the request is unnecessary, as it's the exact same request.
It happens because the query key becomes unstable, but the request is immutable. So there needs to be some kind of way on the success callback to set that the delimiter in the query cache..
How would you solve this kind of quirk?
Beta Was this translation helpful? Give feedback.
All reactions