diff --git a/docs/typescript.md b/docs/typescript.md index f3982e7..86c8aae 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -1314,19 +1314,42 @@ export const Progress: FC> = forwardRef + ```tsx import React, { ElementType, ComponentPropsWithoutRef } from "react"; -export const Link = = "a">(props: { as?: T; } & ComponentPropsWithoutRef) => { +export const Link = = "a">( + props: { as?: T; } & ComponentPropsWithoutRef +) => { const Comp = props.as || "a"; return ; }; + + +文本; ``` 允许传入自定义 `React` 组件,或 `div`, `a` 标签 +### 组件作为 Props 传递 + +```tsx +type RowProps = { + element: React.ElementType<{ + className?: string; + }>; +} +const Row = (props: RowProps) => { + return ( + + ); +}; + +; +; +``` + 各种各样的技巧 ---