Skip to content

A route component should unmount before navigation happens #3538

Closed
@sto3psl

Description

@sto3psl

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:

  1. Click on Route 2 link
  2. Click on Home link
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions