diff --git a/packages/react-router/src/link.tsx b/packages/react-router/src/link.tsx index 31088ede192..c1d42e2184f 100644 --- a/packages/react-router/src/link.tsx +++ b/packages/react-router/src/link.tsx @@ -593,11 +593,7 @@ export function createLink( export const Link: LinkComponent<'a'> = React.forwardRef( (props, ref) => { const { _asChild, ...rest } = props - const { - type: _type, - ref: innerRef, - ...linkProps - } = useLinkProps(rest as any, ref) + const { type: _type, ...linkProps } = useLinkProps(rest as any, ref) const children = typeof rest.children === 'function' @@ -606,20 +602,13 @@ export const Link: LinkComponent<'a'> = React.forwardRef( }) : rest.children - if (_asChild === undefined) { + if (!_asChild) { // the ReturnType of useLinkProps returns the correct type for a element, not a general component that has a disabled prop // @ts-expect-error - delete linkProps.disabled + const { disabled: _, ...rest } = linkProps + return React.createElement('a', rest, children) } - - return React.createElement( - _asChild ? _asChild : 'a', - { - ...linkProps, - ref: innerRef, - }, - children, - ) + return React.createElement(_asChild, linkProps, children) }, ) as any