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

Function useLinkProps

packages/react-aria/src/utils/openLink.tsx:206–219  ·  view source on GitHub ↗
(props?: LinkDOMProps)

Source from the content-addressed store, hash-verified

204}
205
206export function useLinkProps(props?: LinkDOMProps): LinkDOMProps {
207 let router = useRouter();
208 // oxlint-disable-next-line react/react-compiler
209 const href = router.useHref(props?.href ?? '');
210 let linkProps: LinkDOMProps = {};
211 if (props) {
212 for (let key of ['href', 'target', 'rel', 'download', 'ping', 'referrerPolicy']) {
213 if (key in props && props[key] !== undefined) {
214 linkProps[key] = key === 'href' ? href : props[key];
215 }
216 }
217 }
218 return linkProps;
219}
220
221export function handleLinkClick(
222 e: ReactMouseEvent,

Callers 4

useLinkFunction · 0.90
useMenuItemFunction · 0.90
useOptionFunction · 0.90
useTabFunction · 0.90

Calls 1

useRouterFunction · 0.70

Tested by

no test coverage detected