JSPM

react-is-deprecated

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16429
  • Score
    100M100P100Q138686F
  • License MIT

Adds an isDeprecated method to the React.PropTypes object

Package Exports

  • react-is-deprecated

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-is-deprecated) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-is-deprecated

Add an isDeprecated to your React PropTypes.

Install

$ npm install --save react-is-deprecated

Usage

react-is-deprecated provides two options for wrapping React.PropTypes. You can use the deprecate function (recommended) to wrap a specific type and output a warning whenever the prop is defined:

static propTypes = {
  deprecated: deprecate(PropTypes.string, `Your message here`)
}

If you'd like to have an isDeprecated function attached to all React.PropTypes options you can use addIsDeprecated.

const PropTypes = addIsDeprecated(React.PropTypes);
...
static propTypes = {
  deprecated: PropTypes.object.isDeprecated('Your message here.')
}

Note: addIsDeprecated returns a copy of the passed PropTypes instance and does not mutate the React.PropTypes. isDeprecated will only work on the PropType object returned.

API

deprecate(propType: React.PropTypes.[type], message: string)

Returns a function wrapping the propType argument with a check to determine if the prop is defined and, if so, log out a warning via console.warn once.

addIsDeprecated(input: React.PropTypes)

Returns an augmented version of React.PropTypes with isDeprecated added to all top level properties.

[type].isDeprecated(message: string)

If you use the addIsDeprecated function to return a new copy of React.PropTypes then each type will have an isDeprecated message. It is identical to deprecate with the exception that it is already bound to the [type] and just accepts the message.

License

MIT © Brandon Dail