ensureQueryData vs prefetchQuery
Hello guys! I'm trying to integrate react-query with tanstack router and I'm a bit confused about ensureQueryData and prefetchQuery
VS
Should I call prefetchQuery or ensureQueryData?
I saw that ensureQueryData means
getQueryData ?? fetchQuery but i'm still confused 😄
Thank you for taking your time to check this!6 Replies
eastern-cyan•11mo ago
Return
ensureQueryData if you want the loader to block, prefetchQuery and don't return the promise otherwise
Dominick went into more detail here https://discord.com/channels/719702312431386674/1003327027849474198/1313780863430819871ratty-blushOP•11mo ago
Ok. Thank you for the link. So ensure is what I need
Do I need to await it? Or just return it
In order to show the pending component
eastern-cyan•11mo ago
In this case there is no difference.
return promise vs return await promise is a Google search of it's owneastern-cyan•11mo ago
Stack Overflow
Difference between
return await promise and return promiseGiven the code samples below, is there any difference in behavior, and, if so, what are those differences?
return await promise
async function delay1Second() {
return (await delay(1000));
}
re...
ratty-blushOP•11mo ago
Thank you!
eastern-cyan•11mo ago
No problem