fixed props
This commit is contained in:
parent
f4e83e0cc8
commit
0931fa8fe5
@ -7,8 +7,7 @@ type Props = {
|
||||
children: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
} & NavLinkProps &
|
||||
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "">;
|
||||
} & NavLinkProps;
|
||||
|
||||
function getURL(to: string): URL {
|
||||
try {
|
||||
@ -26,12 +25,14 @@ export default function Link({
|
||||
children,
|
||||
disabled,
|
||||
className,
|
||||
style,
|
||||
...props
|
||||
}: Props) {
|
||||
const link =
|
||||
getURL(to).hostname === window.location.hostname ? (
|
||||
<NavLink
|
||||
to={getURL(to).pathname}
|
||||
style={style}
|
||||
className={classNames({ "pointer-events-none": disabled }, className)}
|
||||
>
|
||||
{children}
|
||||
@ -39,6 +40,13 @@ export default function Link({
|
||||
) : (
|
||||
<a
|
||||
href={disabled ? undefined : getURL(to).origin}
|
||||
style={
|
||||
typeof style === "function"
|
||||
? style({
|
||||
isActive: true,
|
||||
})
|
||||
: style
|
||||
}
|
||||
aria-disabled={disabled}
|
||||
{...props}
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user