Skip to content

Commit 097c8fc

Browse files
abeljohnsnowystingerLFDanLu
authored
fix conditional useHref call (#7032)
Co-authored-by: Abel John <[email protected]> Co-authored-by: Robert Snow <[email protected]> Co-authored-by: Daniel Lu <[email protected]>
1 parent 988b4d4 commit 097c8fc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/@react-aria/utils/src/openLink.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ function openSyntheticLink(target: Element, modifiers: Modifiers) {
148148

149149
export function useSyntheticLinkProps(props: LinkDOMProps) {
150150
let router = useRouter();
151+
const href = router.useHref(props.href ?? '');
151152
return {
152-
'data-href': props.href ? router.useHref(props.href) : undefined,
153+
'data-href': props.href ? href : undefined,
153154
'data-target': props.target,
154155
'data-rel': props.rel,
155156
'data-download': props.download,
@@ -172,8 +173,9 @@ export function getSyntheticLinkProps(props: LinkDOMProps) {
172173

173174
export function useLinkProps(props: LinkDOMProps) {
174175
let router = useRouter();
176+
const href = router.useHref(props?.href ?? '');
175177
return {
176-
href: props?.href ? router.useHref(props?.href) : undefined,
178+
href: props?.href ? href : undefined,
177179
target: props?.target,
178180
rel: props?.rel,
179181
download: props?.download,

0 commit comments

Comments
 (0)