JSPM

prop-desc

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 19
    • Score
      100M100P100Q54615F
    • License MIT

    Add metadata to React prop-types

    Package Exports

    • prop-desc

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prop-desc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    prop-desc

    License npm package Build Status DevDependencies

    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.

    npm install prop-desc prop-types

    Example

    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 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