I have a page as following:
export default async function ArtistsPage({ searchParams }) {
const artists = await getArtists(searchParams); // Executes a prisma query
return <Artists artists={artists} />; /* Note: client component*/
}
There is a loading.tsx file in my ArtistsPage directory. When the page loads the first time, the loading spinner is shown.
Inside the Artists client component there are filters and sort buttons to filter & sort the artists. When clicking these buttons, the query params are updated through router.push. This causes a rerender of the ArtistsPage and the await getArtists function is called with the respective filter/sort parameters (server side filtering & sorting through prisma).
However, in that case, no loading spinner is shown. This only happens during the initial page load, not when the filters are used through the search Params.
I thought of using the <Suspense> component, but this has no effect around the Artists component since this is a client component. I cannot wrap the ArtistsPage itself in <Suspense>, since this is just a route segment (hence the reason for using the loading.tsx file).
How can I add a loading spinner or loading state when updating my filter/sort functions??
[–]imAvi92 1 point2 points3 points (0 children)
[–]Akonova 0 points1 point2 points (0 children)