From 097c8fcc7ae47f300246819f520d2ee8796408e0 Mon Sep 17 00:00:00 2001 From: Abel John Date: Thu, 19 Sep 2024 15:44:24 -0700 Subject: [PATCH] fix conditional useHref call (#7032) Co-authored-by: Abel John <9206066+abeljohn@users.noreply.github.com> Co-authored-by: Robert Snow Co-authored-by: Daniel Lu --- packages/@react-aria/utils/src/openLink.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@react-aria/utils/src/openLink.tsx b/packages/@react-aria/utils/src/openLink.tsx index 489e4f6275b..e0b099508cc 100644 --- a/packages/@react-aria/utils/src/openLink.tsx +++ b/packages/@react-aria/utils/src/openLink.tsx @@ -148,8 +148,9 @@ function openSyntheticLink(target: Element, modifiers: Modifiers) { export function useSyntheticLinkProps(props: LinkDOMProps) { let router = useRouter(); + const href = router.useHref(props.href ?? ''); return { - 'data-href': props.href ? router.useHref(props.href) : undefined, + 'data-href': props.href ? href : undefined, 'data-target': props.target, 'data-rel': props.rel, 'data-download': props.download, @@ -172,8 +173,9 @@ export function getSyntheticLinkProps(props: LinkDOMProps) { export function useLinkProps(props: LinkDOMProps) { let router = useRouter(); + const href = router.useHref(props?.href ?? ''); return { - href: props?.href ? router.useHref(props?.href) : undefined, + href: props?.href ? href : undefined, target: props?.target, rel: props?.rel, download: props?.download,