-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(router-view): reuse saved instances in different records #446
Conversation
size-limit report
|
The problem with this fix is that it doesn't fix update and leave guards inside <router-view :key="$route.path" /> but that would also recreate routes with different params. A more appropriate solution would be using the record's path (doesn't include parsed params and it unique) and the name of the view ( <!-- path is here the record's path e.g. /users/:id -->
<router-view name="named" :key="'named_' + $route.matched[depth].path" />
<router-view :key="'default_' + $route.matched[depth].path" /> This information could be exposed through the <router-view v-slot="{ Component, key }" >
<component :key="key" :is="Component" class="view" />
</router-view> Another solution would be able to enforce this automatically inside Another problem with reusing the same component instance for two different routes is that guards added inside |
2105a3c
to
aad8c73
Compare
BREAKING CHANGE: `onBeforeRouteLeave` and `onBeforeRouteUpdate` used to have access to the component instance through `instance.proxy` but given that: 1. It has been marked as `internal` (vuejs/core#1849) 2. When using `setup`, all variables are accessible on the scope (and should be accessed that way because the code minimizes better) It has been removed to prevent wrong usage and lighten Vue Router
20ffe71
to
6400619
Compare
At the end I manage to find a solution that reuses view instances so I went with that instead |
Close #444
Still worth adding edge cases