Sometimes, we want to fix the ‘Avoided redundant navigation to current location’ error in Vue.js.
In this article, we’ll look at how to fix the ‘Avoided redundant navigation to current location’ error in Vue.js.
How to fix the ‘Avoided redundant navigation to current location’ error in Vue.js?
To fix the ‘Avoided redundant navigation to current location’ error in Vue.js, we can call $router.push
only if the route isn’t the same as the current route.
For instance, we write
if (this.$route.path !== "/dashboard") {
this.$router.push("/dashboard");
}
to check if the current route isn’t /dashboard
with
this.$route.path !== "/dashboard"
If it’s true
, then we go to /dashboard
with
this.$router.push("/dashboard");
Conclusion
To fix the ‘Avoided redundant navigation to current location’ error in Vue.js, we can call $router.push
only if the route isn’t the same as the current route.