vercel / next.js

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

Docs: Docs show multiple default.js file used for parallel routes, but never explain why #58796

Open Flammae opened 10 months ago

Flammae commented 10 months ago

What is the improvement or update you wish to see?

Update the docs to specify significance of including two default.js files or mark this as a bug

Is there any context that might help us understand?

The graphic shows multiple default.js file being used for parallel routes. One inside the app root and the other inside @analytics. It's the first graphic if you follow the link below. Both default.js files are highlighted to indicate the importance, but it's never actually explained why there are two of those.

I also downloaded the nextgram example to check it out myself and I found it also had two default.js files, one in app root and the other in @modal. What's more confusing is that the default.js file inside the app folder never actually mounts, but if you delete it, nextjs throws an error:

./src/app/default.tsx
Error: Failed to read source code from C:\Users\user\projects\learning\nextgram\src\app\default.tsx

Caused by:
    The system cannot find the file specified. (os error 2)

I can't tell if this is a bug or incomplete docs issue. On one hand, the root default.js doesn't do anything and breaks the app if deleted, but on the other hand, nextjs team seems aware enough to include it both on the docs graphic and in the example.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#unmatched-routes

Flammae commented 10 months ago

Update: Deleting the cache solved the issue of Next breaking when trying to access deleted root default.js file. It was obsolete as I suspected.

I still can't tell if default.js file outside @folders has any special meaning or not

tyler-dot-earth commented 9 months ago

I'm similarly confused by the documentation about what files are needed to mount and unmount parallel route slots as expected.

For example / similarly - I'm unable to reproduce the dismissing the modal via [...catchAll] section of the docs successfully; the modal (via parallel route) does not unmount when navigating via Link href (only via router hook methods like router.back() or router.push() then router.refresh())