Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 04-linking-and-navigating.mdx, Partial Rendering, explain about unmounting and losing state #70397

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

niecnasowa
Copy link

What?

Update 04-linking-and-navigating.mdx, 4. Partial Rendering section, add information that rerenders of sibling routes mean full rerender of the page, unmounting and losing the state of the page

Why?

I've spent a lot of time trying to understand why in the app router when switching between sibling routes (and Dynamic Segments) I lose scroll position. Finally, find a discussion that this is the intentional behaviour of the Next.js team. Would be good if the Next.js users could find information in the documentation instead of searching for issues and discussions in the documentation.

#50711

How?

Updated docs

@ijjk ijjk added the Documentation Related to Next.js' official documentation. label Sep 24, 2024
@ijjk
Copy link
Member

ijjk commented Sep 24, 2024

Allow CI Workflow Run

  • approve CI run for commit: 0281cdd

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@lyleunderwood
Copy link

I think it's more correct to say that the components will be unmounted and remounted, and thus lose state.

@@ -263,7 +263,7 @@ Learn more about how the [Router Cache](/docs/app/building-your-application/cach

Partial rendering means only the route segments that change on navigation re-render on the client, and any shared segments are preserved.

For example, when navigating between two sibling routes, `/dashboard/settings` and `/dashboard/analytics`, the `settings` and `analytics` pages will be rendered, and the shared `dashboard` layout will be preserved.
For example, when navigating between two sibling routes, `/dashboard/settings` and `/dashboard/analytics`, the `settings` and `analytics` pages will be fully rendered (pages will unmount and state will be lost), and the shared `dashboard` layout will be preserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, when navigating between two sibling routes, `/dashboard/settings` and `/dashboard/analytics`, the `settings` and `analytics` pages will be fully rendered (pages will unmount and state will be lost), and the shared `dashboard` layout will be preserved.
For example, when navigating between two sibling routes, `/dashboard/settings` and `/dashboard/analytics`, the `settings` page will be unmounted, the `analytics` page will be mounted with fresh state, and the shared `dashboard` layout will be preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Related to Next.js' official documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants