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

beforeRouteEnter not triggered when component is reused #1322

Closed
nirazul opened this issue Apr 11, 2017 · 6 comments
Closed

beforeRouteEnter not triggered when component is reused #1322

nirazul opened this issue Apr 11, 2017 · 6 comments

Comments

@nirazul
Copy link

nirazul commented Apr 11, 2017

Version

2.4.0

Reproduction link

http://jsfiddle.net/yj21tp09/

Steps to reproduce

  1. Open the fiddle
  2. Switch between routes (should work)
  3. Change version to 2.4.0
  4. Switch between routes (doesn't work)

What is expected?

In older versions I was able to reuse a component with different paths. The beforeRouteEnter hook was triggered nonetheless.

What is actually happening?

In 2.4.0 this behaviour is broken. The hook isn't called anymore.


This seems to be a direct consequence of #750 as match.instances is empty for the route changes that don't work.

@posva
Copy link
Member

posva commented Apr 11, 2017

BTW you can provide versions when using unpkg.com: http://jsfiddle.net/posva/xjoojctq/

@nirazul
Copy link
Author

nirazul commented Apr 11, 2017

@posva I'm not sure what you mean, I've included the script like that to switch between two vue-router versions within one fiddle.

@posva
Copy link
Member

posva commented Apr 11, 2017

Sorry, it wasn't clear, I meant that you don't need to make it complicated, you can just pass the version in the script tag, it'll be enough to check 🙂
Also make sure to use unpkg and not npmcdn (it got renamed)

@nirazul
Copy link
Author

nirazul commented Apr 11, 2017

Ah, I understand. Thanks for clearing things up.

@francoisromain
Copy link

francoisromain commented Apr 15, 2017

It looks like it's not only the beforeRouteEnter hook which doesn't work, but any router method when a component is reused. (p.e.: $router.replace, router-link :to, etc.)

@xxRockOnxx
Copy link

but if beforeRouteEnter does not work how come next() gets called? But even then, my data are not updating even if it's called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants