Skip to content

Commit

Permalink
Fixed 72
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Aug 8, 2023
1 parent 27a1313 commit aa01465
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ComponentProps,
ComponentPropsWithRef,
ElementType,
ForwardedRef,
forwardRef,
Expand All @@ -21,15 +21,18 @@ type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any
? Omit<T, TOmitted>
: never;

function UnwrappedLink<T extends ElementType>(
export const UnwrappedLink = <TAs extends ElementType>(
props: {
as?: T;
} & DistributiveOmit<ComponentProps<ElementType extends T ? "a" : T>, "as">,
as?: TAs;
} & DistributiveOmit<
ComponentPropsWithRef<ElementType extends TAs ? "a" : TAs>,
"as"
>,
ref: ForwardedRef<any>,
) {
) => {
const { as: Comp = "a", ...rest } = props;
return <Comp {...rest} ref={ref}></Comp>;
}
};

const Link = fixedForwardRef(UnwrappedLink);

Expand Down

0 comments on commit aa01465

Please sign in to comment.