Skip to content

Commit

Permalink
fix(router): skip RouterLink when props.to is empty
Browse files Browse the repository at this point in the history
fixes #19549
  • Loading branch information
yuwu9145 committed Apr 15, 2024
1 parent d368340 commit 4ccb96a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/vuetify/src/composables/router.tsx
Expand Up @@ -64,15 +64,10 @@ export function useLink (props: LinkProps & LinkListeners, attrs: SetupContext['
href: toRef(props, 'href'),
}
}

// vue-router useLink `to` prop needs to be reactive and useLink will crash if undefined
const linkProps = computed(() => ({
...props,
to: toRef(() => props.to || {}),
}))

const routerLink = RouterLink.useLink(linkProps.value as UseLinkOptions)
// Actual link needs to be undefined when to prop is not used
const link = computed(() => props.to ? routerLink : undefined)
const link = computed(() => props.to ? RouterLink.useLink(props as UseLinkOptions) : undefined)

const route = useRoute()

return {
Expand Down

0 comments on commit 4ccb96a

Please sign in to comment.