0.2.2 • Published 6 years ago

junction-proptype-decorator v0.2.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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