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

fix(runtime-core): hydration should not be performed during the HMR reload process(fix #7706) #8170

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

Conversation

Jevon617
Copy link

Close #7706.

During HMR reload, the div element is unmounted. However, in SSR mode, the mountComponent process does not remount the div element but hydrates it instead, causing the issue of the div element is deleted.

@@ -1327,7 +1332,7 @@ function baseCreateRenderer(
}
toggleRecurse(instance, true)

if (el && hydrateNode) {
if (el && hydrateNode && !isHmrReloading) {
Copy link
Member

@edison1105 edison1105 Oct 16, 2024

Choose a reason for hiding this comment

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

This is not the proper fix. if the initial VNode has el it means it needs hydration. so the proper fix should clear vnode.el before reload.

context.reload = () => {
// casting to ElementNamespace because TS doesn't guarantee type narrowing
// over function boundaries
render(
cloneVNode(vnode),
rootContainer,
namespace as ElementNamespace,
)
}
}

changes to

const cloned = cloneVNode(vnode)
cloned.el = null
render( 
  cloned, 
  rootContainer, 
  namespace as ElementNamespace, 
) 

BTW, this PR requires a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

HMR not working after failed hydration
2 participants