The Vue.js 2 Master Class
Plans from $25/month

This lesson is for members. Join us?

Subscribe now to get instant access to this course, plus a full library of Vue.js courses tailored to the plan you choose.

🚧 NOTICE: You are watching a Vue.js 2 lesson

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!