Next.js Discord

Discord Forum

Changes to searchParams don't render loading.tsx

Unanswered
Southern African anchovy posted this in #help-forum
Open in Discord
Southern African anchovyOP
Hello, my app has the following structure
search/
├─ loading.tsx
├─ page.tsx


In page.tsx results are fetched and passed down to a display component
const SearchPage = async (props: SearchPageProps) => {
  const searchParams = await props.searchParams;

  const results = await postSearch({
    filters: searchParams
  });

  return (
    <SearchResults
      filters={searchParams}
      results={results}
    />
  );
};


On an initial visit to the search route the skeleton within loading.tsx is displayed, however when I push (from useRouter) a new set of search params to the same route, the page "hangs" while new content is rendered, rather than displaying the skeleton again.

How can I render the loading.tsx skeleton on subsequent data fetches? Thanks

0 Replies