-
Notifications
You must be signed in to change notification settings - Fork 2.1k
trigger app.$mount in beforeResolve #3820
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
Conversation
| if (!from.name) return next() // do not resolve asyncData on server render - already been done | ||
| if (!from.name) { | ||
| next() | ||
| if (canBeMounted()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be executed before next()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is that vue-router doesn't reveal when it resolve async components. So I check when this.pending is falsy, because it gets null just after enter events are finished (here). In this line it adds this.router.resolveHooks (beforeResolve) to other enter events. So we need to wait just after beforeResolve is finished and then we have falsy this.pending. Best solution would be mounting app after queue ends (here) in onReady, but I couldn't find any flag to check this before it goes to beforeResolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to keep app mounting in onReady callback because in production version on for example homepage there could be a situation that beforeResolve event is not triggered at all.
Related issues
closes #3669
Short description and why it's useful
Problem occur because we mount app before async route component is resolved. So we can use
beforeResolve. As described in vue-router docs it's triggered "after all in-component guards and async route components are resolved". We only need to check if app is already loaded.QA
src/themes/default/router/index.jsto
This will simulate very long lazy loading.
2. check homepage in dev and prod mode => it should crash in prod and there should be mismatch in dev mode
Which environment this relates to
Check your case. In case of any doubts please read about Release Cycle
developbranch and want to merge it back todevelopreleasebranch and want to merge it back toreleasehotfixormasterbranch and want to merge it back tohotfixUpgrade Notes and Changelog
IMPORTANT NOTICE - Remember to update
CHANGELOG.mdwith description of your changeContribution and currently important rules acceptance