prop-types
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/prop-types package

15.5.7-alpha • Public • Published

prop-types

Runtime type checking for React props and similar objects.

Installation

npm install --save prop-types

Importing

import PropTypes from 'prop-types'; // ES6
var PropTypes = require('prop-types'); // ES5 with npm

If you prefer a <script> tag, you can get it from window.PropTypes global:

<!-- development version -->
<script src="https://unpkg.com/prop-types/prop-types.js"></script>
 
<!-- production version -->
<script src="https://unpkg.com/prop-types/prop-types.min.js"></script>

Development and Production Versions

In production, all validator functions are replaced with empty functions that throw an error. This is done to optimize the bundle size.

Don’t call the validator functions manually in your code. React automatically calls PropTypes validators declared on your components in development version, and it won’t call them in production.

If you use a bundler like Browserify or Webpack, don’t forget to follow these instructions to correctly bundle your application in development or production mode. Otherwise you’ll ship unnecessary code to your users.

Usage

Refer to the React documentation for more information.

Migrating from React.PropTypes

Check out Migrating from React.PropTypes for details on how to migrate to prop-types from React.PropTypes

Readme

Keywords

Package Sidebar

Install

npm i prop-types@15.5.7-alpha

Version

15.5.7-alpha

License

BSD-3-Clause

Last publish

Collaborators

  • ljharb
  • fb
  • sophiebits