プログラミングのゴミ箱

日々の学習の中で知らなかったことについて、調べたことを解説します。

typescriptのantdで独自コンポーネントを定義するときのprops

How to extend an Ant Design component - DEV Community
↑これが参考


typescriptのantdで独自コンポーネントを作るときにantdのpropsはそのまま受け継いで、他に自分が定義したpropsも受け取りたいんだけどどうしたらいいんだろうとちょっと詰まったのでメモ。

例えば、antdのButtonを拡張するときは、

import { Button, ButtonProps } from "antd"

type Props = {
    hoge: string,
    fuga: boolean
} & ButtonProps

const chanichi:FC<Props> = (props) => {
    ...
}

こんな感じで拡張できる。antd日本語の情報少なすぎ。