Is there a way to replace getQueriesData altogether #4405
-
Hi there, again. Sorry to bother, but I can't figure out one thing. TL;DR:
It seems strange to me that you get specific type of data and can't use the same data to update the cache. Is there way around such a behavior so I could update the chosen cache instances altogether? Or is the only way to do so is to iterate over queryKeys, compare them to the corresponding data, generate new sets of data for each key and then use some kind of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I'd do:
so the idea is to run Note that previous data can be potentially undefined (because you could match queries that are in loading state or have no data because they are disabled). The code I've shown also only works in v4 because only there, you can return undefined from the updater as well. |
Beta Was this translation helpful? Give feedback.
I'd do:
so the idea is to run
setQueriesData
, which is fuzzy, and it will give you all "old" data for each matching key. Then, you can decide upon that if you want to perform an update or not. You can just return the previous data if it doesn't match what you are looking for.Note that previous data can be potentially undefined (because you could match queries that are in loading state or have no data because they are disabled). The code I've shown also only works in v4 because only there, you can return undefined from the updater as well.