Couldn't get pendingComponent to render
I know I'm using
createServerFn from Start, but I think this is more of a Router question, so I think it fits here.
Anyway. I'm working on a fresh Start project via pnpm create @tanstack/start@latest. I'm still new to the whole Tanstack stack. I'm reading the doc about Data Loading, and in the Showing a pending component section, it is said that pendingComponent will be shown when it takes more than 1 sec for the loader to resolve.
EDIT
It actually works on page navigation, but not on browser page refresh, which was what I tested originally. I'm still wrapping my head around SSR, but I assume this is working as intended.Data Loading | TanStack Router React Docs
Data loading is a common concern for web applications and is related to routing. When loading a page for your app, it's ideal if all of the page's async requirements are fetched and fulfilled as early...
4 Replies
graceful-blueOP•2mo ago
Let say I have this fetcher function
So my first impression is this would trigger the pending component (this is a common data fetching pattern shown throughout the doc and Youtube tutorials)
but it didn't. It seems that the rendering is blocked until the promises are resolved.
I've tried using React 19
use hook and wrap the consumer component in Suspense
However, it's still not displaying the pending component.
Finally, I've tried using Query
Again. Still not showing. So now I'm running out of ideas. Maybe I'm missing something?
My deps FYI
Okay, I just checked again. The pendingComponent works when the page is loaded via in-app navigation (e.g. the Link component). It didn't work when the page first loaded and reloaded. I assume this is the expected behaviorgraceful-blueOP•2mo ago
Repro if anyone is interested
https://github.com/akmalmzamri/tanstack-start-data-loading-patterns
GitHub
GitHub - akmalmzamri/tanstack-start-data-loading-patterns: Common d...
Common data loading and access patterns in Tanstack Start - akmalmzamri/tanstack-start-data-loading-patterns
sensitive-blue•2mo ago
this is start related, hence not the right place, so next time please use #start-questions
in start, the initial response will block until the loaders are finished
if you dont want that, return a nested promise (e.g. in an object) from a loader
then
uses that promise or <Await> it in your component to render the pending componentgraceful-blueOP•2mo ago
Thanks