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

Suspense doesn't work with keepAlive #3652

Closed
Urobs opened this issue Apr 22, 2021 · 5 comments
Closed

Suspense doesn't work with keepAlive #3652

Urobs opened this issue Apr 22, 2021 · 5 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: keep-alive scope: suspense

Comments

@Urobs
Copy link

Urobs commented Apr 22, 2021

Version

3.0.11

Reproduction link

https://codesandbox.io/s/hidden-flower-y164t?file=/src/App.vue

Steps to reproduce

  1. Open the reproduction link
  2. clickadd count
  3. click to about page
  4. error appear: TypeError Cannot read property 'parentNode' of null

What is expected?

keep alive works

What is actually happening?

it doesn't work

@HcySunYang
Copy link
Member

This link explains how these components work together, their order is very important https://v3.vuejs.org/guide/migration/suspense.html#combining-with-other-components, but unfortunately, there are still bugs here

@mahnouel
Copy link

mahnouel commented Apr 5, 2022

I'm no vue internals expert, but I ran into the same error when using suspense, and it seems to be caused by prevTree.el being undefined. When I place another vue component next to the error throwing one, prevTree.el seems to be set, and I get no error anymore.

@723386252
Copy link

723386252 commented Jun 14, 2022

you can try to add attribute incluce to <keep-alive></keep-alive> to resolve

@mauril26
Copy link

This link explains how these components work together, their order is very important https://v3.vuejs.org/guide/migration/suspense.html#combining-with-other-components, but unfortunately, there are still bugs here

Update: https://vuejs.org/guide/built-ins/suspense.html#combining-with-other-components

@posva
Copy link
Member

posva commented Jul 19, 2022

This one is working when using the correct order:

  <router-view v-slot="{ Component, route }">
    <template v-if="Component">
      <KeepAlive>
        <Suspense>
          <!-- main content -->
          <component :key="route.path" :is="Component"></component>

          <!-- loading state -->
          <template #fallback>
            Loading...
          </template>
        </Suspense>
      </KeepAlive>
    </template>
  </router-view>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: keep-alive scope: suspense
Projects
Status: Done
Development

No branches or pull requests

6 participants