Skip to content

activated hook is not called when using defineAsyncComponent #5095

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

Closed
pikax opened this issue Dec 12, 2021 · 0 comments · Fixed by #5459
Closed

activated hook is not called when using defineAsyncComponent #5095

pikax opened this issue Dec 12, 2021 · 0 comments · Fixed by #5459
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working scope: keep-alive

Comments

@pikax
Copy link
Member

pikax commented Dec 12, 2021

Version

3.2.26

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Just opening the SFC playground link

<script>
import {
  defineAsyncComponent,
  defineComponent,
  reactive,
} from 'vue'
import Comp from './Comp.vue'
  
const AsyncComp = defineAsyncComponent(() => Promise.resolve(Comp));

export default defineComponent({
  components: {
    Comp,
    AsyncComp,
  },
  setup () {
    const received = reactive({})
    
    return {
      received,
      
      Comp, 
      AsyncComp,
    }
  },
})
</script>

<template>
  <div>C:{{ received }}</div>

  <keep-alive>
     <Comp @activated="received.comp = true" />
  </keep-alive>
  <keep-alive>
    <AsyncComp @activated="received.asyncComp = true" />
  </keep-alive>
  
  
  <keep-alive>
     <component :is="Comp" @activated="received.comp2= true" />
  </keep-alive>
  <keep-alive>
    <component :is="AsyncComp" @activated="received.asyncComp2= true" />
  </keep-alive>
</template>

What is expected?

Is expected that the activate hook will also run on the AsyncDynamicComponent child

What is actually happening?

Not being called


Not sure if this behaviour is intended, but it differs from vue 2.x

@posva posva added ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working scope: keep-alive labels Feb 10, 2022
iwusong pushed a commit to iwusong/core that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working scope: keep-alive
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants