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

throw TypeError when unmounting Teleport after hydration #11400

Closed
AyatoEbata opened this issue Jul 19, 2024 · 7 comments · Fixed by #11456
Closed

throw TypeError when unmounting Teleport after hydration #11400

AyatoEbata opened this issue Jul 19, 2024 · 7 comments · Fixed by #11456

Comments

@AyatoEbata
Copy link

AyatoEbata commented Jul 19, 2024

Vue version

3.4.32

Link to minimal reproduction

https://stackblitz.com/edit/github-5tkgxx?terminal=dev
https://stackblitz.com/edit/github-wszpet

Steps to reproduce

  1. direct access to index
  2. click to page1
  3. throw error when redirecting

What is expected?

No error when redirecting

What is actually happening?

throw type error and unable to redirect

error

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vue: ^3.4.32 => 3.4.32

Any additional comments?

No response

@edison1105
Copy link
Member

edison1105 commented Jul 19, 2024

Could you please provide a minimal reproduction without VueFinalModal or file an issue to VueFinalModal first.

@AyatoEbata AyatoEbata changed the title throw TypeError when using VueFinalModal throw TypeError when using Teleport Jul 19, 2024
@AyatoEbata
Copy link
Author

@edison1105
https://stackblitz.com/edit/github-wszpet
This is a minimal reproduction without VueFinalModal.
This may be a bug regarding Teleport.

@dadajam4
Copy link

The same issue is occurring with my product as well. After switching through different Vue versions, I confirmed that it does not occur in version 3.4.31 but does occur in version 3.4.32.

@madskronborg
Copy link

The same issue is occurring with my product as well. After switching through different Vue versions, I confirmed that it does not occur in version 3.4.31 but does occur in version 3.4.32.

We experience the same in our Nuxt application. Navigation between pages without a layout and a page with a layout breaks in vue 3.4.32 and 3.4.33 but works as expected in 3.4.31.

Instead of page content getting replaced when navigating, the app changes the browser URL but the content of the old page remains while console contains the error mentioned in this issue.

@obulat
Copy link

obulat commented Jul 24, 2024

The new targetStart property of the teleport vnode is not populated when hydrating an SSR-rendered teleport. So,
n1 here is not null, but does not have targetStart:

process(
n1: TeleportVNode | null,

So, the error in this issue is thrown when the remove function is called on this node here:

if (target) {
hostRemove(targetStart!)
hostRemove(targetAnchor!)
}

This breaks the navigation from server-rendered pages with a teleport.

@urbgimtam
Copy link

urbgimtam commented Jul 25, 2024

Adding a condition to Teleport tag mitigates the issue, like <Teleport v-if="true">.

@ZTL-UwU
Copy link

ZTL-UwU commented Jul 29, 2024

Is it okay to just add a null check in the remove function?

if (target) {
-  hostRemove(targetStart!) 
-  hostRemove(targetAnchor!)
+  if (targetStart) hostRemove(targetStart)
+  if (targetAnchor) hostRemove(targetAnchor)
}

@yyx990803 yyx990803 changed the title throw TypeError when using Teleport throw TypeError when unmounting Teleport after hydration Jul 31, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants