-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
add "href" property to ResolvedRoute #364
Conversation
✅ Deploy Preview for kitbag-router ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -39,5 +40,6 @@ export function getResolvedRouteForUrl(routes: Routes, url: string, state?: unkn | |||
params: getRouteParamValues(route, url), | |||
state: getStateValues(route.state, state), | |||
hash, | |||
href: asUrl(url) |
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.
Seems a little odd we need asUrl. But I get why.
|
||
```html{3} | ||
<router-view> | ||
<template #default={ component, route }> | ||
<transition name="fade" :key="route.key"> | ||
<transition name="fade" :key="route.href"> |
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.
Did you add href to RouterRoute?
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.
yep
id: route.id, | ||
matched: route, | ||
matches: [route], | ||
name: type, | ||
query: createResolvedRouteQuery(''), | ||
params: {}, | ||
state: {}, | ||
href: '/', |
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.
Hmm hard coding this to '/' is interesting. This is really only used for NotFound when the initialUrl doesn't match anything right?
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.
yes that's where we use this reject route. The actual href
of the rejection route is probably never actually used anywhere but required to satisfy the type
Co-authored-by: Craig Harshbarger <[email protected]>
this is step 1 of a couple different initiatives.
1.) we need a key that's unique to handle transitions when params change, currently using
route.id
but that won't change when params change. With this newhref
property, we will have a better candidate. (this is really just a 1 line docs change, so I decided to commit it here)2.) we want to avoid "widening" the route inside of RouterLink, currently users might use an explicit route name as part of the
ToCallback
which uses RouterResolve and returns a Url. Once we "widen" from an explicit route name to a Url, we've found that will sometimes actually point to a different route now, causing a bad DX and confusion.