From 6c7d393cff87e773240f39858ee4b7ef0ce298d4 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 7 Sep 2023 12:44:04 +0800 Subject: [PATCH] doc: update docs/typescript.md --- docs/typescript.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) 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 ( + + ); +}; + +; +; +``` + 各种各样的技巧 ---