Package Exports
- prop-types
- prop-types/checkPropTypes
- prop-types/factory
- prop-types/package.json
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 (prop-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
prop-types
Runtime type checking for React props and similar objects.
Installation
npm install --save prop-typesImporting
import PropTypes from 'prop-types'; // ES6
var PropTypes = require('prop-types'); // ES5 with npmIf 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