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

Function useLinkProps

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

Source from the content-addressed store, hash-verified

187}
188
189export function useLinkProps(props?: LinkDOMProps): LinkDOMProps {
190 let router = useRouter();
191 // oxlint-disable-next-line react/react-compiler
192 const href = router.useHref(props?.href ?? '');
193 let linkProps: LinkDOMProps = {};
194 if (props) {
195 for (let key of ['href', 'target', 'rel', 'download', 'ping', 'referrerPolicy']) {
196 if (key in props && props[key] !== undefined) {
197 linkProps[key] = key === 'href' ? href : props[key];
198 }
199 }
200 }
201 return linkProps;
202}
203
204export function handleLinkClick(
205 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