Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2 Beta issue: router link effect is being run before the route component is unmounted #4148

Closed
AlexandreBonaventure opened this issue Jul 19, 2021 · 4 comments

Comments

@AlexandreBonaventure
Copy link
Contributor

Version

3.2.0-beta.1

Reproduction link

https://github.com/AlexandreBonaventure/vue3.2-bug
https://codesandbox.io/s/funny-monad-3sgle

Screen Shot 2021-07-19 at 10 14 16 AM

Steps to reproduce

Click on 'Go to Route A' then on 'Go to Route B' and observe the error thrown in the console

What is expected?

It should not throw any error and switch route correctly (works with vue<3.2)

What is actually happening?

Error

@posva
Copy link
Member

posva commented Jul 19, 2021

Trying to boil it down without Vue Router by simulating the injected $route but still haven't found it.

A much simpler repro is without nested routes, nor redirects:

import { h } from '@vue/runtime-core'
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    name: 'a',
    path: '/a/:id',
    component: () => import('./ARoute.vue'),
  },
  {
    name: 'b',
    path: '/b',
    component: { render: () => h('div', 'B content') },
  },
]

export const router = createRouter({
  history: createWebHistory(),
  routes,
})

ARoute.vue

<template>
  <pre>{{ $route.params.id.toUpperCase() }}</pre>
</template>

App.vue

<template>
  <nav class="flex pa4" style="gap: 30px">
    <RouterLink :to="{ name: 'a', params: { id: 'test' } }">Go to A</RouterLink>
    <RouterLink :to="{ name: 'b' }">Go to B</RouterLink>
  </nav>
  <RouterView />
</template>

@posva
Copy link
Member

posva commented Jul 19, 2021

Closing in favor of #4149

@yyx990803
Copy link
Member

FYI this is not entirely the same as #4149 as it also involves a scheduler bug where computed scheduler jobs are not correctly appended (fixed in d810a1a)

@AlexandreBonaventure
Copy link
Contributor Author

FYI, I upgraded to 3.2.0-beta-2 and while the repro is now working, our repo that initiated this issue is still failing. Will update soon

@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants