File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed
packages/react-router/src Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -593,11 +593,7 @@ export function createLink<const TComp>(
593593export const Link : LinkComponent < 'a' > = React . forwardRef < Element , any > (
594594 ( props , ref ) => {
595595 const { _asChild, ...rest } = props
596- const {
597- type : _type ,
598- ref : innerRef ,
599- ...linkProps
600- } = useLinkProps ( rest as any , ref )
596+ const { type : _type , ...linkProps } = useLinkProps ( rest as any , ref )
601597
602598 const children =
603599 typeof rest . children === 'function'
@@ -606,20 +602,13 @@ export const Link: LinkComponent<'a'> = React.forwardRef<Element, any>(
606602 } )
607603 : rest . children
608604
609- if ( _asChild === undefined ) {
605+ if ( ! _asChild ) {
610606 // the ReturnType of useLinkProps returns the correct type for a <a> element, not a general component that has a disabled prop
611607 // @ts -expect-error
612- delete linkProps . disabled
608+ const { disabled : _ , ...rest } = linkProps
609+ return React . createElement ( 'a' , rest , children )
613610 }
614-
615- return React . createElement (
616- _asChild ? _asChild : 'a' ,
617- {
618- ...linkProps ,
619- ref : innerRef ,
620- } ,
621- children ,
622- )
611+ return React . createElement ( _asChild , linkProps , children )
623612 } ,
624613) as any
625614
You can’t perform that action at this time.
0 commit comments