The Vue3 unMounted event will not be triggered when using removeNodeId and clear
See original GitHub issueHi, I found a problem. The Vue3 unMounted event will not be triggered when using removeNodeId and clear.
App.vue:
<template>
<div>
<button @click="remove">remove</button>
<div class="box"></div>
</div>
</template>
<script>
import HelloWorldVue from "./components/HelloWorld.vue";
import { h, ref, render, defineComponent, onMounted } from "vue";
import Drawflow from "drawflow";
import "drawflow/dist/drawflow.min.css";
const Vue = { version: 3, h, render };
export default defineComponent({
name: "App",
components: {},
setup() {
const editor = ref();
onMounted(() => {
editor.value = new Drawflow(document.querySelector(".box"), Vue);
editor.value.registerNode("hello", HelloWorldVue, {}, {});
editor.value.start();
editor.value.addNode("ddd", 1, 1, 200, 200, "ddd", {}, "hello", "vue");
});
const remove = () => {
editor.value.removeNodeId("node-1");
};
return {
remove,
};
},
});
</script>
HelloWorld.vue
<script>
export default {
name: "HelloWorld",
props: {
msg: String,
},
mounted() {
console.log("component mount");
},
unmounted() {
console.log("component unmount");
},
};
</script>
Look console, not show “component unmount” when clicking the remove button.
How to solve it?
Thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
VUE 3 Force unmount when deactivated - Stack Overflow
What I want to do is to unmount a page-component from keep-alive cache when it is deactivated . /* this is the loaded...
Read more >Event handlers fire after `umounted`. Unlike Vue 2 ... - GitHub
Event handlers should not run after a component is unmounted. As it stands, this is an undocumented breaking change between Vue 2 and...
Read more >Options: Lifecycle | Vue.js
However, the mounting phase has not been started, and the $el property will not be ... Called right before a component instance is...
Read more >A Complete Guide to Vue Lifecycle Hooks - with Vue 3 Updates
beforeCreate() – Options API. Since the created hook is the thing that initializes all of the reactive data and events, beforeCreate does not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tomasp1189
Sorry, I don’t understand what you mean. Can’t trigger unmount event in inserted component via Drawflow when you are using navigation?
Like this? It will trigger a remove event when the page changes navigation.
@rni-l Thanks! Yeah, I have something similar. My issue is when I clear it programmatically or when navigating away. I can’t get the unmount then.