We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 35b5af3 commit 2ca5d6bCopy full SHA for 2ca5d6b
src/08-advanced-patterns/71-as-prop-with-default.problem.tsx
@@ -1,13 +1,13 @@
1
-import { ComponentPropsWithoutRef, ElementType } from "react";
+import { ElementType } from "react";
2
import { Equal, Expect } from "../helpers/type-utils";
3
4
-export const Link = <T extends ElementType>(
+export const Link = <TAs extends ElementType>(
5
props: {
6
- as: T;
7
- } & ComponentPropsWithoutRef<T>,
+ as: TAs;
+ } & React.ComponentPropsWithoutRef<TAs>,
8
) => {
9
- const Comp = props.as;
10
- return <Comp {...(props as any)}></Comp>;
+ const { as: Comp = "a", ...rest } = props;
+ return <Comp {...rest}></Comp>;
11
};
12
13
/**
0 commit comments