T
TanStack•3y ago
like-gold

does `ensureQueryData()` respect `staleTime` or is it only concerned with cached data?

I'm having a heck of a time trying to figure out how to use the local storage persister. it does not behave the way i expect and i can't make sense of it.
2 Replies
relaxed-coral
relaxed-coral•3y ago
is this two separate questions? ensureQueryData doesn't have much to do with persisters ...
like-gold
like-goldOP•3y ago
hey @TkDodo 🔮 i think the questions are related though. If i was a typescript wizard i think i would Omit staleTime from the ensureQueryData() options i think i'm dealing with a combination of issues, persister, misunderstanding of ensureQueryData(), react router loader timing react strict mode i think i could solve my problems if i could listen to the isRestoring flag outside of a hook.
async function rootLoader() {
await new Promise(resolve => {
while (queryClient.isRestoring()) {}
resolve()
})

// proceed to use ensureQueryData()
}
async function rootLoader() {
await new Promise(resolve => {
while (queryClient.isRestoring()) {}
resolve()
})

// proceed to use ensureQueryData()
}

Did you find this page helpful?