Show Loading
I'm trying to figure out how to show my loading spinner when the todo is streaming from the server:
Currently, it never loads.
J
6 Replies
Yeah, because of
deferStream: true
ssr will wait for that async to resolve first
if you disable client side js and check the response, you should see that async signal right in the html in seroval encoded formCurrently, it never loads.Even later during CSR the
getTodo
will suspend all the way up to the Suspense boundary in the app.tsx
:
Try this instead:
If I move the Suspense to the child component, I get a Hydration Mismatch... however, if I have two Suspense it works.
Is it correct usage to have two <Suspense> tags? I'm thinking this is not correct, but it works? J
Is it correct usage to have two <Suspense> tags? I'm thinking this is not correct, but it works? J
Is it correct usage to have two <Suspense> tags?You can have as many as you need. Suspense simply demarcates a section of the UI with impending changes due to asynchronous operations it depends on: - and therefore shows its
fallback
or
- holds its stale content if it is part of the current transition, delaying visually updating until all of the asynchronous operations under the suspense boundary have settled.great thanks!
If I move the Suspense to the child component, I get a Hydration Mismatch…I suspect that you need the top level suspense boundary for SSR to work reliably. When there are asynchronous operations within the component tree that aren't under a suspense boundary undesirable things tend to happen during SSR. Imagine the unsettled promise of a resource/async being thrown towards the root, shredding through everything on its way and not being caught by a suspense boundary that can try again once all the promises under it have settled (perhaps not technically accurate but metaphorically a good image).