It is not possible to rewrite cacheTime when using queryClient.setQueryData #2146
Replies: 4 comments 8 replies
-
Not sure what issue you are trying to solve, what’s your use case? setQueryData can set the query data, not query options. However, number 2 in your list should work. useQuery accepts a cacheTime option: https://react-query.tanstack.com/reference/useQuery |
Beta Was this translation helpful? Give feedback.
-
Thanks @TkDodo, The issue I’m facing, is that I haven’t been able to set cacheTime when using setQueryData(...). This is my question: Is there any way to set cacheTime when using useQueryData?. |
Beta Was this translation helpful? Give feedback.
-
if that's the question then the answer is: no, it's not possible. but I don't think that is the question. You're clearly trying to solve a problem by setting cacheTime via setQueryData, and I would like to know what that use-case is. Maybe there is a completely different way of solving that problem that doesn't have anything to do with setting cacheTime via setQueryData. But you need to describe your problem in order for me to help out here :) |
Beta Was this translation helpful? Give feedback.
-
It would be awesome if serQueryData had the option to set data duration on
cache memory.
…On Mon, Aug 9, 2021 at 7:48 AM Dominik Dorfmeister ***@***.***> wrote:
setQueryData only sets data, I don't see why it should set anything else
🤔
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2146 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKCJP52R3JPKVHQE7OTOCDT37FCVANCNFSM5BZT7PFQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm iterating through a result array and using setQueryData to memoize individual results. I also have a specific hook to fetch these results individually with userQuery(...). I've tried to set the cacheTime other than 5 mins and it's been not possible when using setQueryData. I've tried many different approaches:
None of them have worked, cacheTime always is 300000 when using querClient.setQueryData.
I'm working with react-query v3.13.10.
Beta Was this translation helpful? Give feedback.
All reactions