Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions packages/react-router/src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,7 @@ export function createLink<const TComp>(
export const Link: LinkComponent<'a'> = React.forwardRef<Element, any>(
(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'
Expand All @@ -606,20 +602,13 @@ export const Link: LinkComponent<'a'> = React.forwardRef<Element, any>(
})
: rest.children

if (_asChild === undefined) {
if (!_asChild) {
// the ReturnType of useLinkProps returns the correct type for a <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

Expand Down
Loading