Get unlimited public & private packages + team-based management with npm Teams.Learn more »

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

Install

npm i react-results-proptypes

DownloadsWeekly Downloads

12

Version

0.5.1

License

WTFPL

Last publish

Collaborators

  • avatar