You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a watcher on $route.query in a component that's only rendered on one route.
Notice that the watcher is triggered when navigating to another route.
If you do the same with Vue 2 / vue-router v3, the watcher is not triggered.
What is expected?
The behaviour is the same as vue-router v3.
What is actually happening?
The behaviour changed!
We have a very common pattern of a watcher on $route.query that fetches data when the URL query changes. Now, because of this change, our app makes many more unnecessary network requests when navigating to different routes.
One potential workaround is to set some global state, like isUnmounting = true, in the router's global before hook (and then unset it in the after hook). Then, we could return early in the watchers if this boolean is true. However, this isn't a very clean solution!
The text was updated successfully, but these errors were encountered:
Version
4.0.14
Reproduction link
codesandbox.io
Steps to reproduce
$route.query
in a component that's only rendered on one route.What is expected?
The behaviour is the same as vue-router v3.
What is actually happening?
The behaviour changed!
We have a very common pattern of a watcher on
$route.query
that fetches data when the URL query changes. Now, because of this change, our app makes many more unnecessary network requests when navigating to different routes.One potential workaround is to set some global state, like
isUnmounting = true
, in the router's global before hook (and then unset it in the after hook). Then, we could return early in the watchers if this boolean is true. However, this isn't a very clean solution!The text was updated successfully, but these errors were encountered: