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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(router-view): render children as placeholder #2799

Closed
wants to merge 2 commits into from

Conversation

briwa
Copy link
Contributor

@briwa briwa commented Jun 4, 2019

This is not a bug, but the way I use router-view is that it has a placeholder using the router-view children before rendering it with the actual view from the component. Here's a little demo:

https://codesandbox.io/s/vue-routing-example-b1t5d

You see that there's a slight delay before the route component gets rendered. It gets quite apparent when you have a beforeEach navigation guard that delays the route to be rendered. The 'blinking' effect between the blank page and the rendered component is undesirable and I am trying to improve it.

I tried using async component to no avail, and it turned out that the cause was when the router is initialized, it is validating an initial route, and it is rendering an empty node since there is no match. This explains the blank page/element that I was facing.

My proposal is to render the children instead of an empty node, so that there is something to be rendered before the route component takes place. This applies to any kinds of route mismatches though. I made a little example and an e2e test to demonstrate the change.

Also, I did search through the issues but none of it seemed to mention this problem (could be very specific to the problem I'm facing, or maybe I missed it, CMIIW), so if this isn't exactly what Vue Router is aiming for, I understand, but maybe you could suggest a solution for me 馃槄. But if this is good enough, that would be so great, though I'm not sure if I'm doing the e2e test right.

Anyhow, let me know! Thanks for Vue Router btw, I've been using it for the past 2 years and it's been terrific.

@posva
Copy link
Member

posva commented Jun 4, 2019

Hey, thanks for this, it's a very detailed and understandable issue, I think it's a good idea and a good opportunity to think about the API of router-view to maybe also handle 404 routes

@posva posva added this to Design proposals + discussion (high prio, high complex) in Longterm Jun 6, 2019
@briwa
Copy link
Contributor Author

briwa commented Jun 7, 2019

@posva I agree, right now what I did with the 404 cases is that they are pretty much handled by backend rendering. Should the changes for the error pages be done in this PR as well? Or is it something to think about later on.

@briwa
Copy link
Contributor Author

briwa commented Jun 12, 2019

@posva Sorry if I bumped this PR again 馃槄 Just in case I wasn't clear. Is there anything else I needed to do in this PR so that it can be reviewed? Thanks.

@posva
Copy link
Member

posva commented Jun 12, 2019

No, nothing to do. I will get into this when I can but it will probably go through an RFC first

@briwa
Copy link
Contributor Author

briwa commented Jun 12, 2019

Understood, thanks @posva

@briwa
Copy link
Contributor Author

briwa commented Aug 9, 2019

Hello @posva, sorry for bumping this PR again after two months. Any updates on the RFC, or maybe I can help with it, so that this PR can get in? Thank you.

@posva
Copy link
Member

posva commented Aug 9, 2019

Hey, no updates yet. You could, if you have the time, prepare an RFC at https://github.com/vuejs/rfcs instead of a PR
Unfortunately there are quite a few other things I need to cover until I get to this

@posva
Copy link
Member

posva commented May 11, 2020

Thank you for the PR. I'm closing it for the moment as we need to wait for vuejs/rfcs#80 and vuejs/rfcs#160

I will reopen if we go forward with the change!

@posva posva closed this May 11, 2020
@posva posva moved this from Design proposals + discussion (high prio, high complex) to Done in Longterm May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants