-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
onBeforeMount and onMount called, but onBeforeUnmount and onUnmount not, if inside <transition> #6260
Comments
The thing is, in our project this inner component uses Teleport. Sometimes the backend sends an error and vue router redirects to the error page - this redirect happens while the Transition is running, and the inner component is mounted but never removed. So all states are still active, including the Teleport content. |
Seems like the following edge-case causes troubles:
|
Closing as it can not reproduce anymore with the latest version. |
Vue version
3.2.27
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-5pepm1?file=src/components/Page1.vue
Steps to reproduce
If component A is itself loading a child component inside a
<transition>
, but A is replaced by B during loading, the child component is only executing the onBeforeMount and onMount hook, but not the Unmount hooks, even though it is removed from the DOM and not visible anymore.This issue only happens if the timing is right. In our project (with vue cli and a lot of stuff) I could reproduce it with a promise of 10ms, and a page transition after 100ms. But in the reproduction link it behaved differently. There it only executes the onBeforeMount and not the onMount, and I see an error which I don't get locally in our project.
What is expected?
onBeforeUnmount and onUnmounted should be called consistently and reliably!
What is actually happening?
Sometimes only the onBeforeMount and onMounted hooks are executed, and not the unmount hooks, even though the component gets destroyed by routing to a different page.
System Info
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: