react-results-proptypes
v0.5.1
Published
proptype validators for results instances
Downloads
3
Maintainers
Readme
Results PropTypes for React
$ 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
wereMaybe.None()
orMaybe.Some('string')
thingFromMyUnion
were any ofMyUnion.A('blah')
,MyUnion.B(42)
,MyUnion.C()