New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prop-types-nullable

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

prop-types-nullable

a small convenience function for allowing explicitly null props with the prop-types package

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
decreased by-32.69%
Maintainers
1
Weekly downloads
 
Created
Source

Prop-Types Nullable

Small convenience function for prop-types which allows explicitly null props but rejects omissions.

Install dependency

npm install --save prop-types-nullable

Usage

This builds on top of prop-types, so see that project's documentation for the basics of the API.

Simple usage:

const nullable = require('prop-types-nullable');

MyReactClass.propTypes = {
  foobar: nullable(PropTypes.func).isRequired,
};

// foobar is now a required property, but can be explicitly null

It is possible to use nullable without isRequired, but this is pointless (as null will be allowed for a non-required property anyway). This project maintains the need for isRequired for consistency with the prop-types API, and to better integrate with linting rules.

See https://github.com/facebook/react/issues/3163 for a discussion around adding similar functionality to the core prop-types project.

FAQs

Package last updated on 29 Aug 2020

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc