vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.33k stars 27.02k forks source link

Nesting Layout Uses Parallel Route Inside Optional Catch-all Segment Reset on Navigation #60037

Open M7ilan opened 11 months ago

M7ilan commented 11 months ago

Link to the code that reproduces this issue

https://github.com/M7ilan/nesting-layout-inside-optional-catch-all-segment-uses-parallel-route-reset-on-navigation

To Reproduce

Open https://issue-60037.vercel.app/ or clone the repo above.

  1. Open the console
  2. Click a book or record.
  3. If the console log this on one click:
    Title Rendered
    Books Rendered
    Records Rendered
    Content Rendered

    That mean the whole layout re-rendered/reset which is a problem.

Current vs. Expected behavior

Currently the app\route\[[...slug]]\layout.tsx is re-rendering/reset on every navigation which also re-renders all the parallel routes inside it.

I expect the app\route\[[...slug]]\layout.tsx to re-renders the changed parallel-routes/components not everything.

Verify canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: 8.13.1
Relevant Packages:
  next: 14.0.5-canary.30
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, Routing (next/router, next/navigation, next/link)

Additional context

No response

TommySorensen commented 10 months ago

In generel Parrallel routes is just buggy. Fx. this error on v. 14.0.4 makes no sense. This should just work and did in v. 14.0.1. It's even worse in canary version. Last issue about this was closed because no one picked up the error in the Next team

image
OmarAfet commented 1 month ago

Just tested this on v14.2.15 and v15.0.0-canary.181 and still encountering the same issue. I'm not sure if it's supposed to work the way I expect, which is to only rerender the modified parallel routes or components while leaving everything else unchanged.