hi
zod 通常是拿來做表單或 api 資料的型別驗證, 我看到的大多作法是自己定義 type, 加上使用 react 的 ComponentProps, 這樣還可以獲得 html 的原始 props。
import { ComponentProps } from "react"; type MyDivProps = ComponentProps<"div"> & { myProp: string; }; const MyDiv = ({ myProp, ...props }: MyDivProps) => { console.log(myProp!); return <div {...props} />; };
參考 : https://www.totaltypescript.com/react-component-props-type-helper
每週二晚上《CodeLove Talk》直播! 開放觀眾 Call-in,一起討論軟體開發相關的話題!
hi
zod 通常是拿來做表單或 api 資料的型別驗證,
我看到的大多作法是自己定義 type,
加上使用 react 的 ComponentProps,
這樣還可以獲得 html 的原始 props。
參考 : https://www.totaltypescript.com/react-component-props-type-helper