diff --git a/packages/components/README.md b/packages/components/README.md index f3e4399fe3d51..df92e8db57be4 100644 --- a/packages/components/README.md +++ b/packages/components/README.md @@ -57,6 +57,19 @@ const Example = () => { }; ``` +### TypeScript + +This package exposes its own types for the components it exports, however it doesn't export its own types for component props. If you need to extract the props type, please use `React.ComponentProps` to get the types from the element. + +```tsx +import type { ComponentProps } from 'react'; +import { Button } from '@wordpress/components'; + +export default function MyButton( props: ComponentProps< typeof Button > ) { + return ; +} +``` + ## Docs & examples You can browse the components docs and examples at [https://wordpress.github.io/gutenberg/](https://wordpress.github.io/gutenberg/)