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
In the linked CodeSandbox open the console and follow these steps:
Click on Route 2 link
Click on Home link
Check URL bar and console output
What is expected?
After navigation from /route to / I should see the correct URL in the URL bar -> / and the console output should be:
Route.vue unmount
Navigated to: /
HelloWorld.vue mounted
What is actually happening?
After navigation from /route to /, the URL bar shows /?test=hello and the console output is:
Navigated to: /
Route.vue watchEffect: /
Route.vue unmount
HelloWorld.vue mounted
By having a watchEffect that depends on the route value this bug causes code to run after a route change happened and can trigger unintended side effects.
The text was updated successfully, but these errors were encountered:
Component mounting is not directly connected to navigation and will never be because there are too many scenarios where it's not always possible. In most scenarios, you can just wait for nextTick():
router.afterEach((to)=>{console.log("Navigated to: ",to.path);nextTick().then(()=>{console.log('actual navigated to')})});
Version
4.0.6
Reproduction link
https://codesandbox.io/s/awesome-albattani-b1uvt
Steps to reproduce
In the linked CodeSandbox open the console and follow these steps:
Route 2
linkHome
linkWhat is expected?
After navigation from
/route
to/
I should see the correct URL in the URL bar ->/
and the console output should be:Route.vue unmount
Navigated to: /
HelloWorld.vue mounted
What is actually happening?
After navigation from
/route
to/
, the URL bar shows/?test=hello
and the console output is:Navigated to: /
Route.vue watchEffect: /
Route.vue unmount
HelloWorld.vue mounted
By having a
watchEffect
that depends on theroute
value this bug causes code to run after a route change happened and can trigger unintended side effects.The text was updated successfully, but these errors were encountered: