combined-proptypes

1.0.0 • Public • Published

combined-proptypes

Example

import PropTypes from 'prop-types';
 
Component.PropTypes = {
  title: PropTypes.string,
  counter: PropTypes.number,
  onPress: PropTypes.func.isRequired
};
 
Component.defaultProps = {
  title: "no title",
  counter: 0
};

becomes:

import { PropTypes, setPropTypes } from 'combined-proptypes';
 
setPropTypes(Component, {
  title: PropTypes.string("no title"),
  counter: PropTypes.number(0),
  onPress: PropTypes.func.isRequired
});

Why combined-proptypes?

  • Centralizes the setting of type and default value for props.
  • Enforces safe coding practices by requiring you to provide a default value for optional props.

Supported PropTypes

Currently the following PropTypes are supported:

PropTypes.array
PropTypes.array.isRequired
PropTypes.string
PropTypes.string.isRequired
PropTypes.bool
PropTypes.bool.isRequired
PropTypes.func
PropTypes.func.isRequired
PropTypes.number
PropTypes.number.isRequired
PropTypes.object
PropTypes.object.isRequired
PropTypes.symbol
PropTypes.symbol.isRequired

More PropTypes might follow if I get around to it ;)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.01latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.01

Package Sidebar

Install

npm i combined-proptypes

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

217 kB

Total Files

10

Last publish

Collaborators

  • xanderd