react-results-proptypes

0.5.1 • Public • Published

Results PropTypes for React

Build Status

$ npm install react-results-proptypes
import { unionOf, maybeOf } from 'react-results-proptypes';
 
// this would be declared somewhere else in the app and imported
const MyUnion = Union({ A: null, B: null, C: null });
 
const MyComponent = React.createClass({
  propTypes: {
    maybeAString: maybeOf(React.PropTypes.string),
    thingFromMyUnion: unionOf(MyUnion, {
      A: React.PropTypes.string,
      B: React.PropTypes.number,
      C: null,
    }),
  },
  ...
});

The component above would pass checks if:

  • maybeAString were Maybe.None() or Maybe.Some('string')
  • thingFromMyUnion were any of
    • MyUnion.A('blah'),
    • MyUnion.B(42),
    • MyUnion.C()

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i react-results-proptypes

    Weekly Downloads

    2

    Version

    0.5.1

    License

    WTFPL

    Last publish

    Collaborators

    • uniphil