vercel / next.js

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

Page is remounted when params change in (optional) catch all routes #66751

Open beckerei opened 4 months ago

beckerei commented 4 months ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/dreamy-firefly-4nsplp

To Reproduce

Start the provided application https://codesandbox.io/p/devbox/dreamy-firefly-4nsplp

  1. click + link
  2. loading page is triggered
  3. locale state is reseted

Current vs. Expected behavior

It looks like the page is remounted, but I actually expected the page to be the same, with changing props. Keeping local state and not triggering the loading page.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.0-canary.25 // Latest available version is detected (15.0.0-canary.25).
  eslint-config-next: N/A
  react: 19.0.0-rc.0
  react-dom: 19.0.0-rc.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

Navigation

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

next dev (local), next start (local)

Additional context

The change in behaviour was introduced in https://github.com/vercel/next.js/releases/tag/v14.3.0-canary.27 and still exists in the latest canary.

I suspect that the behavior was introduced in https://github.com/vercel/next.js/pull/65063

When using parallel routes with a catch all segment on the main route it will retrigger loading boundaries when navigation is only relevant for the parallel route slot.

beckerei commented 1 day ago

This is now part of the 14.2.15 release and will prevent us from upgrading past 14.2.14.

Behaviour until 14.2.14

https://github.com/user-attachments/assets/823c50e7-fe66-4ca3-9b24-b3dafab1d02f

Behaviour from 14.2.15

https://github.com/user-attachments/assets/ea1bfee2-1f28-4a20-b5f1-d78ca8a6578c

Running the dev server without turbo