Replies: 1 comment
-
|
Give the route a export const Route = createFileRoute('/org/activities/meetups/$meetupId')({
staleTime: 60_000,
loader: ({ params }) => ({
meetupPromise: fetchMeetup(params.meetupId),
}),
component: MeetupLayout,
})
function MeetupLayout() {
const { meetupPromise } = Route.useLoaderData()
return (
<div className="max-w-2xl mx-auto bg-neutral-900 border border-neutral-800 p-8 rounded-2xl shadow-xl">
<Await promise={meetupPromise} fallback={<MeetupDetailsSkeleton />}>
{(meetup) => <MeetupDetails meetup={meetup} />}
</Await>
</div>
)
}Within Docs: https://tanstack.com/router/latest/docs/framework/react/guide/data-loading and https://tanstack.com/router/latest/docs/framework/react/guide/deferred-data-loading |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to implement a loading indicator inside of a part of my component. The tutorial I was following used
pendingComponent()to show a loading indictator on the initial data fetch. This is not ideal for what I wanted to build off of it. I would like to take advantage of the SWR rendering, but also be able to place the loading indicator INSIDE my component, so that the indicator is inside the bounds where the content being loaded would exist.The only way I can get anything close to this, is to write my template twice. Once with the data as the
componentand once inside thependingComponent()function with the added loading indicator.I have tried something along these lines to get the indicator to show up, however the indicator ALWAYS shows up, and that just completely voids the benefit of the built in SWR caching Tanstack provides, which is to use cached data to provide a more snappy user experience by removing the loading screens from subsequent navigations to the same route withthin the allotted stale data time:
Beta Was this translation helpful? Give feedback.
All reactions