Learn Vue JS course Learn Javascript and Vue JS Learn VueJS course Learn VueJS Tutorial
Learn Vue.js with Vue School #1 SOURCE OF VUE.JS KNOWLEDGE

The Vue.js Master Class

Get access to this course, 10 others, and future Vue.js courses!

Start Learning

Already got an account? Log in

Force Vue Router to Destroy Component to Trigger Lifecycle Hooks

In this lesson, we're learning how to force the vue router to destroy the component when we're navigating to another route that are using the same "PageComponent". This is important when you're relying on Vue's lifecycle hooks, for example as we do to fetch vital data from our database.

If we do not force the vue router to destroy the current component when we're navigating to another route, the router will try to be smart and just swap the props and the URL. This means that a new component will not be created and the lifecycle hook not fired!