-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathlink.tsx
More file actions
36 lines (32 loc) · 1016 Bytes
/
link.tsx
File metadata and controls
36 lines (32 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @deprecated This component will be replaced by the Element component in the future.
* Use Element with tag="a" instead.
*/
import { forwardRef, type ComponentProps } from "react";
export const defaultTag = "a";
type Props = Omit<ComponentProps<"a">, "target" | "download"> & {
// override (string & {}) in target to generate keywords
target?: "_self" | "_blank" | "_parent" | "_top";
download?: boolean;
prefetch?: "none" | "intent" | "render" | "viewport";
preventScrollReset?: boolean;
reloadDocument?: boolean;
replace?: boolean;
};
export const Link = forwardRef<
HTMLAnchorElement,
Props & { $webstudio$canvasOnly$assetId?: string | undefined }
>((props, ref) => {
const {
children,
// @todo: it's a hack made for Image component for the builder and should't be in the runtime at all.
$webstudio$canvasOnly$assetId,
...rest
} = props;
return (
<a {...rest} href={rest.href ?? "#"} ref={ref}>
{children}
</a>
);
});
Link.displayName = "Link";