junction-proptype-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Junction PropType Decorator

Requirements: Node.js 6+

Map your Junction entity schema to an output suitable for React prop validation

Install

npm install junction-proptypes-decorator --save

Usage

Decorate your schema-defined entities with @proptypeable and access the custom prop type via the shape getter.

@proptypeable
class Car {

  wheels = 4;
  electric = true;

}

Car.schema = {
  type: 'entity',
  props: {
    wheels: {
      type: 'number',
      isRequired: true
    },
    electric: {
      type: 'boolean',
      isRequired: true
    }
  }
}

class CarRow extends Component {

  static propTypes = {
    car: Car.shape.isRequired
  }

  ...
}

Licence

MIT

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i junction-proptype-decorator

    Weekly Downloads

    2

    Version

    0.2.2

    License

    MIT

    Unpacked Size

    78.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • andy-shea