New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

combined-proptypes

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

combined-proptypes

A react library that combines both propTypes and defaultProps into one function call.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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

Keywords

combined

FAQs

Package last updated on 13 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts