ensure vs prefetch query in deferred data loading
I'm trying to understand the difference between
From the tanstack router docs:
Then in the component:
I get why we don't
But from the docs it seems like the main diff. between the two is that
But for instance, why can't both use
ensureQueryData and prefetchQueryData, esepcially in the context of deferred loading.From the tanstack router docs:
Then in the component:
I get why we don't
await the prefetch query, since we want to let it resolve in a <Suspense /> block.But from the docs it seems like the main diff. between the two is that
prefetch will never throw, and ensureQueryData will prefer to serve cached data.But for instance, why can't both use
prefetch or both use ensure?