react-extra-prop-types
v0.3.1
Published
Extra PropTypes for use with React components
Downloads
9,264
Maintainers
Readme
react-extra-prop-types
Includes some additional React PropTypes for common use cases. No dependencies.
PropTypes
integer
- invalid if prop is non-integercolor
- invalid if prop is not valid CSS color string (rgb(a), hsl(a), hex). Excludes keywords.datetime
- invalid if prop is not string which can be passed to JavaScriptDate
constructor with valid resultuuid
- invalid if prop is not valid UUID
Usage
require
-ing
var ExtraPropTypes = require('react-extra-prop-types');
var color = ExtraPropTypes.color;
var uuid = ExtraPropTypes.uuid;
// or ...
var color = require('react-extra-prop-types/lib/color');
var uuid = require('react-extra-prop-types/lib/uuid');
use just like normal PropTypes
MyReactComponent.propTypes = {
id: ExtraPropTypes.integer,
name: React.PropTypes.string,
lastFetchTime: ExtraPropTypes.datetime
};
props are optional unless .isRequired
is used
MyReactComponent.propTypes = {
id: ExtraPropTypes.integer.isRequired // can't be left out
};
Development
See CONTRIBUTING.md.