https://github.com/smooth-code/prop-desc
React prop-types with metadata inside ✨
https://github.com/smooth-code/prop-desc
documentation prop-types react
Last synced: 12 months ago
JSON representation
React prop-types with metadata inside ✨
- Host: GitHub
- URL: https://github.com/smooth-code/prop-desc
- Owner: smooth-code
- License: mit
- Created: 2019-08-10T09:03:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T14:23:22.000Z (over 5 years ago)
- Last Synced: 2025-04-02T06:22:18.025Z (about 1 year ago)
- Topics: documentation, prop-types, react
- Language: JavaScript
- Size: 271 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# prop-desc
[](https://github.com/smooth-code/prop-desc/blob/master/LICENSE)
[](https://www.npmjs.com/package/prop-desc)
[](https://travis-ci.org/smooth-code/prop-desc)
[](https://david-dm.org/smooth-code/prop-desc?type=dev)
React prop-types with metadata inside ✨
It is a drop-in replacement for prop-types that includes metadata to generate documentation from prop-types consistently.
```sh
npm install prop-desc prop-types
```
## Example
```js
import React from 'react'
import PropTypes from 'prop-desc'
function MyComponent() {
// ... do things with the props
}
MyComponent.propTypes = {
optionalArray: PropTypes.array,
optionalBool: PropTypes.bool,
optionalFunc: PropTypes.func,
}
console.log(PropTypes.getMetadata(MyComponent.propTypes))
```
## Why?
Generating documentation from prop types is useful but not easy. A project call [react-docgen](https://github.com/reactjs/react-docgen) try to introspect code to extract type but it remains static and does not work with complex prop types (in other files). prop-desc solves this and permits to generate consistent documentation from your prop-types.
# License
MIT