Skip to content

Commit 9ac77a1

Browse files
committed
Changed the way that 70 starts out
1 parent 782759d commit 9ac77a1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/08-advanced-patterns/70-as-prop-with-custom-components.problem.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ import { Equal, Expect } from "../helpers/type-utils";
1717
* - ComponentPropsWithRef
1818
* - ComponentProps
1919
*/
20-
export const Wrapper = (props: { as: unknown }) => {
21-
const Comp = props.as;
22-
return <Comp {...props}></Comp>;
20+
export const Wrapper = <TAs extends keyof JSX.IntrinsicElements>(
21+
props: {
22+
as: TAs;
23+
} & React.ComponentProps<TAs>,
24+
) => {
25+
const Comp = props.as as string;
26+
27+
return <Comp {...(props as any)}></Comp>;
2328
};
2429

2530
/**

0 commit comments

Comments
 (0)