prop-types
Runtime type checking for React props and similar objects.
Installation
npm install --save prop-types
Importing
import PropTypes from 'prop-types';
var PropTypes = require('prop-types');
If you prefer a global:
<script src="https://unpkg.com/prop-types/prop-types.js"></script>
<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.