MCPcopy Create free account
hub / github.com/adobe/react-spectrum / handleLinkClick

Function handleLinkClick

packages/react-aria/src/utils/openLink.tsx:204–223  ·  view source on GitHub ↗
(
  e: ReactMouseEvent,
  router: Router,
  href: Href | undefined,
  routerOptions: RouterOptions | undefined
)

Source from the content-addressed store, hash-verified

202}
203
204export function handleLinkClick(
205 e: ReactMouseEvent,
206 router: Router,
207 href: Href | undefined,
208 routerOptions: RouterOptions | undefined
209): void {
210 // If a custom router is provided, prevent default and forward if this link should client navigate.
211 if (
212 !router.isNative &&
213 e.currentTarget instanceof HTMLAnchorElement &&
214 e.currentTarget.href &&
215 // If props are applied to a router Link component, it may have already prevented default.
216 !e.isDefaultPrevented() &&
217 shouldClientNavigate(e.currentTarget, e) &&
218 href
219 ) {
220 e.preventDefault();
221 router.open(e.currentTarget, e, href, routerOptions);
222 }
223}

Callers 2

useLinkFunction · 0.90
onClickFunction · 0.90

Calls 2

shouldClientNavigateFunction · 0.85
openMethod · 0.65

Tested by

no test coverage detected