1
1
mirror of https://github.com/mdx-js/mdx.git synced 2024-09-17 18:37:48 +03:00

Add notes on how to type props and components

Closes GH-2510.

Reviewed-by: Titus Wormer <tituswormer@gmail.com>
This commit is contained in:
Karl Horky 2024-07-12 11:48:38 +02:00 committed by GitHub
parent 044e8b2a27
commit 95ba33e154
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,5 @@
import {Note} from '../_component/note.jsx'
export const info = {
author: [
{github: 'wooorm', name: 'Titus Wormer', twitter: 'wooorm'}
@ -206,6 +208,13 @@ console.log(React.createElement(Example, {name: 'Venus', year: 2021}))
console.log(<Example name="Mars" year={2022} />)
```
<Note type="info">
**Note**:
Users of the MDX VS Code extension can add type
checking of `props` with a JSDoc comment.
See [`mdx-js/mdx-analyzer`][mdx-analyzer] for more info.
</Note>
### Components
There is one special prop: `components`.
@ -383,6 +392,13 @@ because in JSX syntax `a` is a literal tag name.
The third link (`#charlie`) is dashed and tomato,
as in JSX syntax `Link` is a reference.
<Note type="info">
**Note**:
Users of the MDX VS Code extension can add type
checking of provided and passed components with a JSDoc comment.
See [`mdx-js/mdx-analyzer`][mdx-analyzer] for more info.
</Note>
### Layout
There is one special component: the layout.
@ -592,6 +608,8 @@ providers: pass components explicitly.
[what]: /docs/what-is-mdx/
[mdx-analyzer]: https://github.com/mdx-js/mdx-analyzer
[mdx-react]: /packages/react/
[mdx-preact]: /packages/preact/