From e7b2156c7436f18d1a08694f502eb00b10029f1c Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 2 Jun 2021 00:02:28 +0200 Subject: [PATCH] fix(link): catch errors --- src/RouterLink.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/RouterLink.ts b/src/RouterLink.ts index aef8e176a..dbee6205b 100644 --- a/src/RouterLink.ts +++ b/src/RouterLink.ts @@ -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 { /** @@ -113,8 +113,12 @@ export function useLink(props: UseLinkOptions) { function navigate( e: MouseEvent = {} as MouseEvent ): Promise { - 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() }