react reconciliation algorithm does not apply between page transitions #16480
Unanswered
abdelrahmantoptal
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When
next/link
does client-side navigation, everything that falls under/inside the Page component subtree gets re-rendered.For example, consider these two pages:
and
According to React docs, because that
div
changes top
, the whole subtree belowdiv
orp
is discarded. It will never be compared with the diff algorithm. But this means thatWrapper
andSidebar
will not be re-rendered.For example when user is on Page1, and made an action that results in a
state
change in the sidebar component instance, it should retain that state when they move to Page2 on client-side navigation withnext/link
, given that Sidebar props never change.However this is not what happens. Everything is re-rendered when clicking the
next/link
(except these elements in _app.tsx, above the Page component)Is that intentional, and the right thing to have?
Beta Was this translation helpful? Give feedback.
All reactions