Socket
Socket
Sign inDemoInstall

react-is-deprecated

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-is-deprecated

Adds an isDeprecated method to the React.PropTypes object


Version published
Weekly downloads
16K
decreased by-0.39%
Maintainers
1
Install size
7.36 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 29 Mar 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc