iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐙

How to extract props types from a component

に公開

I needed the props type for Storybook but didn't want to export it.

Method 1

import { ComponentProps } from 'react'

type Props = ComponentProps<typeof TargetComponent>

Method 2 (Old)

type Props = Parameters<typeof TargetComponent>[0]
GitHubで編集を提案

Discussion