Skip to content

Commit 2ca5d6b

Browse files
committed
Changed the start of 71
1 parent 35b5af3 commit 2ca5d6b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/08-advanced-patterns/71-as-prop-with-default.problem.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { ComponentPropsWithoutRef, ElementType } from "react";
1+
import { ElementType } from "react";
22
import { Equal, Expect } from "../helpers/type-utils";
33

4-
export const Link = <T extends ElementType>(
4+
export const Link = <TAs extends ElementType>(
55
props: {
6-
as: T;
7-
} & ComponentPropsWithoutRef<T>,
6+
as: TAs;
7+
} & React.ComponentPropsWithoutRef<TAs>,
88
) => {
9-
const Comp = props.as;
10-
return <Comp {...(props as any)}></Comp>;
9+
const { as: Comp = "a", ...rest } = props;
10+
return <Comp {...rest}></Comp>;
1111
};
1212

1313
/**

0 commit comments

Comments
 (0)