Next.js Discord

Discord Forum

what loading.tsx structure do I need?

Unanswered
Mallow bee posted this in #help-forum
Open in Discord
Mallow beeOP
This is a simple todo app

todos/
  [id]/
    loading.tsx # matches item page
    page.tsx # item page
  loading.tsx # matches index page
  page.tsx # index page


- when I refresh the item page, I see the loading.tsx for the item page
- when I refresh the index, I see the loading.tsx for the index page

however when I click one of the items in the index, I see the index loading.tsx while the item page is loading. Instead I want to see the loading.tsx for the item page there. Is there a way to make this work or do I have to drop down to suspense boundaries?

13 Replies

Mallow beeOP
hard refresh in browser
no real relevant code, just the file structure
loading.tsx files are just skeleton layouts that look like the page-clients
which are big client components representing the whole page and are rendered by the page.tsx server components (who fetch data and pass it as props)
Mallow beeOP
oh this might be a false positive, I just deployed and I'm getting the expected results
maybe the dev server cached an old loading.tsx
@Mallow bee maybe the dev server cached an old loading.tsx
Yes, because I'm on latest stable version, and its working fine for me
Try deleting .next folder
Mallow beeOP
I might need to make a habit of restarting dev server after changing loading.tsx
I sometimes face this issue, and restarting sometimes help, but in some cases, I also need to delete .next folder