Skip to content

A callback to next() of beforeRouteEnter executed before mounted() #3472

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

Closed
MaciejJanyska opened this issue Feb 9, 2021 · 2 comments
Closed

Comments

@MaciejJanyska
Copy link

MaciejJanyska commented Feb 9, 2021

Version

3.4.6+

Reproduction link

https://codesandbox.io/s/vue-router-346-bgn2c

Steps to reproduce

  1. Open "Page 1" from the header

What is expected?

The right order of the executions of callback in next() of beforeRouteEnter and mounted.

What is actually happening?

The order of the executions of callback in next() of beforeRouteEnter and mounted are different in different version of view-router
Here is a reproduction link to the same sandbox with vue-router 3.4.5

@posva
Copy link
Member

posva commented Feb 9, 2021

This is likely to be related to #2875.

The behavior is still correct as one shouldn't rely on the ordering among created/mounted (component lifecycle hooks) and navigation hooks like beforeRouteEnter() because the order is not guaranteed and dependant of features like transitions, keep alive and other combinations and therefore, unreliable.

The only thing that is part of the API, and that can be made clearer in docs, is that the component renders once (DOM updates triggered) before calling the next callbacks.

@posva posva closed this as completed Feb 9, 2021
@MaciejJanyska
Copy link
Author

MaciejJanyska commented Feb 9, 2021

Please note that the same example app has completely different behavior relates to the vue-router version. Unfortunately same thing happened in our company's application. It's a pity that the issue was closed immediately :(

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

No branches or pull requests

2 participants