Skip to content

Commit

Permalink
Add component props docs (#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 <[email protected]>

---------

Co-authored-by: mikeybinns <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: rafaucau <[email protected]>
  • Loading branch information
4 people authored Apr 2, 2024
1 parent f4178a2 commit 1655ed0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/components/README.md
Original file line number Diff line number Diff line change
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 1655ed0

Please sign in to comment.