Socket
Socket
Sign inDemoInstall

prop-types-annotated

Package Overview
Dependencies
5
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prop-types-annotated

Prop types, but with type metadata


Version published
Maintainers
1
Install size
147 kB
Created

Readme

Source

prop-types-annotated

A tiny wrapper around the PropTypes library that does not change its functionality, but provides some extra metadata on a React component's prop types.

For example, if you have a component like this:

import React from 'react';
import PropTypes from 'annotated-prop-types';

export default MyComponent extends React.Component {
  static propTypes = {
    name: PropTypes.string.isRequired
  };

  render() {
    return <h1>hello {this.props.name}!</h1>;
  }
}

Then, elsewhere, you could import this component and get some information from its propTypes:

import MyComponent from './my-component';

console.log(MyComponent.propTypes.name.metadata);
// -> {type: "string", isRequired: true}

This is especially helpful when generating documentation (e.g. props tables) straight from a component's source code.

FAQs

Last updated on 17 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc