Skip to content

Commit

Permalink
fix(link): catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jun 1, 2021
1 parent 46a354e commit e7b2156
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/RouterLink.ts
Expand Up @@ -17,7 +17,7 @@ import { isSameRouteLocationParams, isSameRouteRecord } from './location'
import { routerKey, routeLocationKey } from './injectionSymbols'
import { RouteRecord } from './matcher/types'
import { NavigationFailure } from './errors'
import { isBrowser } from './utils'
import { isBrowser, noop } from './utils'

export interface RouterLinkOptions {
/**
Expand Down Expand Up @@ -113,8 +113,12 @@ export function useLink(props: UseLinkOptions) {
function navigate(
e: MouseEvent = {} as MouseEvent
): Promise<void | NavigationFailure> {
if (guardEvent(e))
return router[unref(props.replace) ? 'replace' : 'push'](unref(props.to))
if (guardEvent(e)) {
return router[unref(props.replace) ? 'replace' : 'push'](
unref(props.to)
// avoid uncaught errors are they are logged anyway
).catch(noop)
}
return Promise.resolve()
}

Expand Down

0 comments on commit e7b2156

Please sign in to comment.