T
TanStack3y ago
vicious-gold

queryCache.findAll(key) weird behaviour

hi. I have a function which returns some cache data but i want it to return undefined while nothing found in that case im getting some strange result return undefined doesnt work and im getting 2 console logs output with and without data can anyone explain why is that happening?
No description
No description
4 Replies
conscious-sapphire
conscious-sapphire3y ago
Where is getAllFetchedItems called?
vicious-gold
vicious-goldOP3y ago
this getAllFetchedItems returned by another function(not executed, function declaration) which is also returned and executed by another function(arrow function). all of these wrapper-functions are synchronious
conscious-sapphire
conscious-sapphire3y ago
Looks like the issue is getAllFetchedItems being called multiple times, if you can show the code maybe we can help figuring out why
vicious-gold
vicious-goldOP3y ago
yea it is. many times. every render(im using react) i guess. but why usual js flow breaks?(undefined doesnt work) this function is made for pagination. im doing queries with some variables(pagination page number) and all of data stored under one key in cache. this is how i get all of the data to render queryCache.findAll is synchronious the docs said

Did you find this page helpful?