Skip to content

Commit

Permalink
Add component props docs (WordPress#60350)
Browse files Browse the repository at this point in the history
* add docs about component props

* Apply suggestions from code review

Co-authored-by: Lena Morita <lena@jaguchi.com>

---------

Co-authored-by: mikeybinns <mikeybinns@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: rafaucau <rafaucau@git.wordpress.org>
  • Loading branch information
4 people authored and cbravobernal committed Apr 9, 2024
1 parent 6fccc08 commit 0b89cc6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/components/README.md
Expand Up @@ -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 <Button { ...props }>Click Me!</Button>;
}
```

## Docs & examples

You can browse the components docs and examples at [https://wordpress.github.io/gutenberg/](https://wordpress.github.io/gutenberg/)
Expand Down

0 comments on commit 0b89cc6

Please sign in to comment.