Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update newest #3

Merged
merged 94 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
10e6583
Include CI for master branch and PR's
Oct 22, 2017
b7d03ce
Point readme to correct docs for production builds (#153)
qstearns Jan 16, 2018
5df7296
15.6.1
Feb 26, 2018
7cc8c81
Add 15.6.1 to CHANGELOG
aweary Feb 27, 2018
c5527c8
Updated vars with consts and lets in PropTypesProductionReact15-test.js
Mar 19, 2018
8e2b34e
Updated vars to consts and lets in PropTypesDevelopmentReact15.js
Mar 19, 2018
c10c93f
Updated vars to consts and lets in PropTypesDevelopmentStandalone-tes…
Mar 19, 2018
d65f80e
Updated vars to consts and lets in PropTypesProductionStandalone-test.js
Mar 19, 2018
2bde8eb
Add example for `PropTypes.exact`
jaller94 Apr 12, 2018
ba3da12
Show that shapes can have required properties
jaller94 Apr 12, 2018
a36cda8
Move explanation of `isRequired` and show it in `PropTypes.shape`
jaller94 Apr 12, 2018
3c99d57
Remove trailing spaces
jaller94 Apr 12, 2018
07d1b47
Remove fbjs dependency
gaearon Jun 19, 2018
d6c9c5c
Preserve "Invariant Violation" name
gaearon Jun 19, 2018
a7a5a64
Merge pull request #194 from facebook/no-fbjs
gaearon Jun 19, 2018
2ac742c
Merge pull request #171 from barrymichaeldoyle/master
gaearon Jun 19, 2018
5115f5c
Merge pull request #180 from jaller94/master
gaearon Jun 19, 2018
fa6fbb7
15.6.2
gaearon Jun 19, 2018
a16a9b1
.com
gaearon Jun 19, 2018
a9ebdeb
Merge pull request #131 from joefraley/master
gaearon Jun 19, 2018
fb7d4d3
Add support for objects with a null prototype in objectOf
getkey Sep 20, 2017
e6a9b28
Replace `hasOwnProperty` with the more robust "has" package
getkey Nov 8, 2017
6fef996
Revert "Replace `hasOwnProperty` with the more robust "has" package"
getkey Jun 19, 2018
2200d8d
Inline the `has` module
getkey Jun 19, 2018
cfc7f43
Merge pull request #112 from getkey/objectof-null-prototype
gaearon Jun 19, 2018
ef3541f
missed semicolon
kirusick Aug 10, 2018
2a5e8fc
[Tests] use componentName in getPropTypeWarningMessage instead of har…
chentsulin Sep 17, 2018
3b39cab
[Fix] Fix `oneOf` when used with Symbols
jimf Oct 2, 2018
a5ce17a
Completely remove envify in favor of loose-envify
autra Aug 9, 2018
b67bbd4
[New] Add `.elementType`
eXon Sep 9, 2018
11e45c4
Add license to readme
gaearon Nov 1, 2018
33e559c
[Fix] Support validation when hasOwnProperty is not in prototype
dferber90 May 29, 2018
8343e81
[Docs] fix relative release date to be absolute
Oct 26, 2018
215265c
[Docs] Fix typo in example
gingur Jan 3, 2019
40af72f
[New] add `PropTypes.resetWarningCache`
Apr 8, 2018
8e3cc5d
[dev deps] update `loose-envify`
ljharb Feb 9, 2019
b4c8170
`oneOf`: improve warning when multiple arguments are supplied
wojtekmaj Dec 18, 2018
36f829e
[changelog] update repo links
ljharb Feb 10, 2019
3807e16
v15.7.0
ljharb Feb 10, 2019
672ff96
[Fix] avoid template literal syntax
ljharb Feb 11, 2019
48eb8fa
v15.7.1
ljharb Feb 11, 2019
456b63c
[Tests] add `eslint`; run more travis tests
ljharb Feb 11, 2019
181d8c9
[Tests] run tests with multiple react versions
ljharb Feb 11, 2019
32114d3
[Fix] move `loose-envify` back to production deps, for browerify usage
ljharb Feb 12, 2019
2ae9e71
[Tests] add additional passing tests
ljharb Feb 13, 2019
6e49d20
[Fix] ensure nullish values in `oneOf` do not crash
ljharb Feb 13, 2019
d93d52d
[dev deps] update `browserify`
ljharb Feb 13, 2019
953ed9b
v15.7.2
ljharb Feb 13, 2019
c38ec30
[Docs] Improve wording for `checkPropTypes`
noscripter Feb 16, 2019
604da17
[Docs] `PropTypes.node`: add link to react docs
ljharb Feb 21, 2019
965f543
[meta] use `in-publish` to avoid running the build on install
ljharb Feb 21, 2019
71bdfe3
`checkPropTypes`: Friendlier message when using a type checker that i…
May 13, 2017
75ddcb8
[Tests] test the build process
ljharb Feb 21, 2019
9e7afa3
[New] Add type check for validator for 'shape' and 'exact'
Oct 26, 2018
4438a18
[Tests] fix broken tests
noscripter Feb 27, 2019
e32c490
[Refactor] extract `has`
noscripter Feb 27, 2019
7161c05
[Docs] Add instructions for intentional inclusion of validation in pr…
rgraffbrd Feb 27, 2019
3910873
[New] `oneOfType`: Add expected types to warning
joshalling Jul 20, 2018
bef0803
[Tests] Fixed typo: 'Any type *should* accept any value'
weiluntong Jul 15, 2019
b44f0f8
[Dev Deps] update `eslint`
conartist6 Aug 30, 2019
4d34e9a
[Deps] update `react-is`
ljharb Aug 31, 2019
d2959d8
[Dev Deps] update `browserify`, `bundle-collapser`, `react`, `uglifyi…
ljharb Aug 31, 2019
1c4077b
[Docs] Typo fix in example
Nov 11, 2019
c78cb69
[Tests] Fix spelling
jbampton Jul 4, 2020
8f89a1c
doc: highlighted the func name (#321)
Jul 22, 2020
d62a775
[readme] Clarify usage of `elementType`
gbroques Feb 9, 2021
0721dd5
[Dev Deps] update `bundle-collapser`, `eslint`, `in-publish`, `react`
ljharb May 18, 2021
3c8bf36
[Deps] update `react-is`
ljharb May 18, 2021
4de0644
Add a package `sideEffects` field.
jaydenseric May 21, 2021
2710ad9
Bump sshpk from 1.13.1 to 1.16.1
dependabot[bot] Sep 2, 2021
8291c36
Use GH Actions
zpao Nov 23, 2021
51282ab
[eslint] enable some rules
KonstHardy Nov 4, 2021
e4e6bb9
Bump path-parse from 1.0.6 to 1.0.7
dependabot[bot] Aug 11, 2021
6b36071
Bump tmpl from 1.0.4 to 1.0.5
dependabot[bot] Sep 21, 2021
239af0d
[deps] regenerate yarn.lock
ljharb Nov 29, 2021
53deaa0
[readme] Fix branch name (master -> main)
KonstHardy Dec 2, 2021
a921554
[Dev Deps] update `eslint`
ljharb Dec 22, 2021
aa90f53
[New] add `PropTypes.bigint`
ljharb Dec 22, 2021
307a0f5
v15.8.0
ljharb Dec 22, 2021
f9d2c19
[Tests] do not fail fast; add react 17
ljharb Dec 23, 2021
bdc31fa
[meta] Fix formatting in CHANGELOG.md
wojtekmaj Dec 28, 2021
88e1b3d
[Tests] convert normal `it` functions to arrow functions
ljharb Jan 4, 2022
b93deca
[Tests] add missing test coverage
ljharb Jan 5, 2022
90c8c47
[Fix] fix crash when a custom propType return lacks `.data`; call `ha…
ljharb Jan 5, 2022
044efd7
[Dev Deps] update `eslint`
ljharb Jan 5, 2022
70330a4
v15.8.1
ljharb Jan 5, 2022
44f8411
docs: add GH button in support of Ukraine (#375)
dmitryvinn Mar 7, 2022
cedc3ac
[Deps] `yarn upgrade`
ljharb Oct 28, 2022
aee5d72
build: harden ci.yml permissions
sashashura Dec 8, 2022
67ae278
Bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 13, 2023
1c9c631
Bump ua-parser-js from 0.7.32 to 0.7.33
dependabot[bot] Jan 27, 2023
554e12e
Merge branch 'main' of github.com:facebook/prop-types into update-newest
MichaelBuessemeyer May 16, 2024
71dd804
remove production env tests as we do not have any production env tests
MichaelBuessemeyer May 16, 2024
baf4da2
update
MichaelBuessemeyer May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prop-types.min.js
34 changes: 34 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"root": true,
"parserOptions": {
"ecmaVersion": 5,
},
"env": {
"browser": true,
"node": true,
},
"rules": {
"no-console": "off",
"no-multi-spaces": ["error"],
"key-spacing": ["error"],
},
"overrides": [
{
"files": "**/__tests__/**/*",
"env": {
"jest": true,
"jasmine": true,
"es6": true,
},
"rules": {
"no-unused-vars": "off",
},
"parserOptions": {
"ecmaVersion": 2019,
"ecmaFeatures": {
"jsx": true,
},
},
},
],
}
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI
on:
- push
- pull_request

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
ci:
name: "Build & Test (React v${{ matrix.react_version}})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
react_version:
- "17"
- "16"
- "16.0"
- "15"
- "15.0"
- "0.14.9"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "lts/*"
cache: 'yarn'
- run: yarn install
- run: yarn add react@${{ matrix.react_version }}
- run: yarn list --pattern 'react'
- run: yarn run pretest
- run: yarn run tests-only
- run: yarn run build
80 changes: 67 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,110 @@
## 15.8.1
* [Fix] fix crash when a custom propType return lacks `.data`; call `hasOwnProperty` properly (#370)
* [meta] Fix formatting in CHANGELOG.md (#367)
* [Tests] add missing test coverage (#370)
* [Tests] convert normal `it` functions to arrow functions (#370)
* [Tests] do not fail fast; add react 17 (#366)
* [Dev Deps] update `eslint`

## 15.8.0
* [New] add `PropTypes.bigint` (#365)
* [New] `oneOfType`: Add expected types to warning (#198)
* [New] Add type check for validator for 'shape' and 'exact' (#234)
* [Fix] `checkPropTypes`: Friendlier message when using a type checker that is not a function (#51)
* [Refactor] extract `has` (#261, #125, #124)
* [readme] Fix branch name (master -> main) (#364)
* [readme] Clarify usage of `elementType` (#335)
* [docs] highlighted the func name (#321)
* [docs] Typo fix in example (#300)
* [docs] Add instructions for intentional inclusion of validation in production. (#262)
* [docs] `PropTypes.node`: add link to react docs
* [docs] Improve wording for `checkPropTypes` (#258)
* [meta] Add a package `sideEffects` field. (#350)
* [meta] use `in-publish` to avoid running the build on install
* [deps] regenerate yarn.lock
* [deps] update `react-is` (#347, #346, #345, #340, #338)
* [eslint] enable some rules (#360)
* [Tests] Use GH Actions (#363)
* [Tests] Fix spelling (#318)
* [Tests] Fixed typo: 'Any type *should* accept any value' (#281)
* [Tests] fix broken tests; test the build process
* [Dev Deps] update `browserify`, `bundle-collapser`, `eslint`, `in-publish`, `react`, `uglifyify`, `uglifyjs`

## 15.7.2
* [Fix] ensure nullish values in `oneOf` do not crash ([#256](https://github.com/facebook/prop-types/issues/256))
* [Fix] move `loose-envify` back to production deps, for browerify usage ([#203](https://github.com/facebook/prop-types/issues/203))

## 15.7.1
* [Fix] avoid template literal syntax ([#255](https://github.com/facebook/prop-types/issues/255), [#254](https://github.com/facebook/prop-types/issues/254))

## 15.7.0
* [New] Add `.elementType` ([#211](https://github.com/facebook/prop-types/pull/211))
* [New] add `PropTypes.resetWarningCache` ([#178](https://github.com/facebook/prop-types/pull/178))
* `oneOf`: improve warning when multiple arguments are supplied ([#244](https://github.com/facebook/prop-types/pull/244))
* Fix `oneOf` when used with Symbols ([#224](https://github.com/facebook/prop-types/pull/224))
* Avoid relying on `hasOwnProperty` being present on values' prototypes ([#112](https://github.com/facebook/prop-types/pull/112), [#187](https://github.com/facebook/prop-types/pull/187))
* Improve readme ([#248](https://github.com/facebook/prop-types/pull/248), [#233](https://github.com/facebook/prop-types/pull/233))
* Clean up mistaken runtime dep, swap envify for loose-envify ([#204](https://github.com/facebook/prop-types/pull/204))

## 15.6.2
* Remove the `fbjs` dependency by inlining some helpers from it ([#194](https://github.com/facebook/prop-types/pull/194)))

## 15.6.1
* Fix an issue where outdated BSD license headers were still present in the published bundle [#162](https://github.com/facebook/prop-types/issues/162)

## 15.6.0

* Switch from BSD + Patents to MIT license
* Add PropTypes.exact, like PropTypes.shape but warns on extra object keys. ([@thejameskyle](https://github.com/thejameskyle) and [@aweary](https://github.com/aweary) in [#41](https://github.com/reactjs/prop-types/pull/41) and [#87](https://github.com/reactjs/prop-types/pull/87))
* Add PropTypes.exact, like PropTypes.shape but warns on extra object keys. ([@thejameskyle](https://github.com/thejameskyle) and [@aweary](https://github.com/aweary) in [#41](https://github.com/facebook/prop-types/pull/41) and [#87](https://github.com/facebook/prop-types/pull/87))

## 15.5.10

* Fix a false positive warning when using a production UMD build of a third-party library with a DEV version of React. ([@gaearon](https://github.com/gaearon) in [#50](https://github.com/reactjs/prop-types/pull/50))
* Fix a false positive warning when using a production UMD build of a third-party library with a DEV version of React. ([@gaearon](https://github.com/gaearon) in [#50](https://github.com/facebook/prop-types/pull/50))

## 15.5.9

* Add `loose-envify` Browserify transform for users who don't envify globally. ([@mridgway](https://github.com/mridgway) in [#45](https://github.com/reactjs/prop-types/pull/45))
* Add `loose-envify` Browserify transform for users who don't envify globally. ([@mridgway](https://github.com/mridgway) in [#45](https://github.com/facebook/prop-types/pull/45))

## 15.5.8

* Limit the manual PropTypes call warning count because it has false positives with React versions earlier than 15.2.0 in the 15.x branch and 0.14.9 in the 0.14.x branch. ([@gaearon](https://github.com/gaearon) in [#26](https://github.com/reactjs/prop-types/pull/26))
* Limit the manual PropTypes call warning count because it has false positives with React versions earlier than 15.2.0 in the 15.x branch and 0.14.9 in the 0.14.x branch. ([@gaearon](https://github.com/gaearon) in [#26](https://github.com/facebook/prop-types/pull/26))

## 15.5.7

* **Critical Bugfix:** Fix an accidental breaking change that caused errors in production when used through `React.PropTypes`. ([@gaearon](https://github.com/gaearon) in [#20](https://github.com/reactjs/prop-types/pull/20))
* Improve the size of production UMD build. ([@aweary](https://github.com/aweary) in [38ba18](https://github.com/reactjs/prop-types/commit/38ba18a4a8f705f4b2b33c88204573ddd604f2d6) and [7882a7](https://github.com/reactjs/prop-types/commit/7882a7285293db5f284bcf559b869fd2cd4c44d4))
* **Critical Bugfix:** Fix an accidental breaking change that caused errors in production when used through `React.PropTypes`. ([@gaearon](https://github.com/gaearon) in [#20](https://github.com/facebook/prop-types/pull/20))
* Improve the size of production UMD build. ([@aweary](https://github.com/aweary) in [38ba18](https://github.com/facebook/prop-types/commit/38ba18a4a8f705f4b2b33c88204573ddd604f2d6) and [7882a7](https://github.com/facebook/prop-types/commit/7882a7285293db5f284bcf559b869fd2cd4c44d4))

## 15.5.6

**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**

* Fix a markdown issue in README. ([@bvaughn](https://github.com/bvaughn) in [174f77](https://github.com/reactjs/prop-types/commit/174f77a50484fa628593e84b871fb40eed78b69a))
* Fix a markdown issue in README. ([@bvaughn](https://github.com/bvaughn) in [174f77](https://github.com/facebook/prop-types/commit/174f77a50484fa628593e84b871fb40eed78b69a))

## 15.5.5

**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**

* Add missing documentation and license files. ([@bvaughn](https://github.com/bvaughn) in [0a53d3](https://github.com/reactjs/prop-types/commit/0a53d3a34283ae1e2d3aa396632b6dc2a2061e6a))
* Add missing documentation and license files. ([@bvaughn](https://github.com/bvaughn) in [0a53d3](https://github.com/facebook/prop-types/commit/0a53d3a34283ae1e2d3aa396632b6dc2a2061e6a))

## 15.5.4

**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**

* Reduce the size of the UMD Build. ([@acdlite](https://github.com/acdlite) in [31e9344](https://github.com/reactjs/prop-types/commit/31e9344ca3233159928da66295da17dad82db1a8))
* Remove bad package url. ([@ljharb](https://github.com/ljharb) in [158198f](https://github.com/reactjs/prop-types/commit/158198fd6c468a3f6f742e0e355e622b3914048a))
* Reduce the size of the UMD Build. ([@acdlite](https://github.com/acdlite) in [31e9344](https://github.com/facebook/prop-types/commit/31e9344ca3233159928da66295da17dad82db1a8))
* Remove bad package url. ([@ljharb](https://github.com/ljharb) in [158198f](https://github.com/facebook/prop-types/commit/158198fd6c468a3f6f742e0e355e622b3914048a))
* Remove the accidentally included typechecking code from the production build.

## 15.5.3

**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**

* Remove the accidentally included React package code from the UMD bundle. ([@acdlite](https://github.com/acdlite) in [df318bb](https://github.com/reactjs/prop-types/commit/df318bba8a89bc5aadbb0292822cf4ed71d27ace))
* Remove the accidentally included React package code from the UMD bundle. ([@acdlite](https://github.com/acdlite) in [df318bb](https://github.com/facebook/prop-types/commit/df318bba8a89bc5aadbb0292822cf4ed71d27ace))

## 15.5.2

**Note: this release has a critical issue and was deprecated. Please update to 15.5.7 or higher.**

* Remove dependency on React for CommonJS entry point. ([@acdlite](https://github.com/acdlite) in [cae72bb](https://github.com/reactjs/prop-types/commit/cae72bb281a3766c765e3624f6088c3713567e6d))
* Remove dependency on React for CommonJS entry point. ([@acdlite](https://github.com/acdlite) in [cae72bb](https://github.com/facebook/prop-types/commit/cae72bb281a3766c765e3624f6088c3713567e6d))


## 15.5.1
Expand All @@ -67,4 +121,4 @@

## Before 15.5.0

PropTypes was previously included in React, but is now a separate package. For earlier history of PropTypes [see the React change log.](https://github.com/facebook/react/blob/master/CHANGELOG.md)
PropTypes was previously included in React, but is now a separate package. For earlier history of PropTypes [see the React change log.](https://github.com/facebook/react/blob/HEAD/CHANGELOG.md)
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The code of conduct is described in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md).
## Pull Requests
We actively welcome your pull requests.

1. Fork the repo and create your branch from `master`.
1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
Expand Down
54 changes: 39 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# prop-types
# prop-types [![Support Ukraine](https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat&labelColor=005BBB)](https://opensource.fb.com/support-ukraine) [![Build Status](https://travis-ci.com/facebook/prop-types.svg?branch=main)](https://travis-ci.org/facebook/prop-types)

Runtime type checking for React props and similar objects.

You can use prop-types to document the intended types of properties passed to
components. React (and potentially other libraries—see the checkPropTypes()
components. React (and potentially other libraries—see the `checkPropTypes()`
reference below) will check props passed to your components against those
definitions, and warn in development if they don’t match.

Expand All @@ -22,8 +22,8 @@ var PropTypes = require('prop-types'); // ES5 with npm

### CDN

If you prefer to exclude `prop-types` from your application and use it
globally via `window.PropTypes`, the `prop-types` package provides
If you prefer to exclude `prop-types` from your application and use it
globally via `window.PropTypes`, the `prop-types` package provides
single-file distributions, which are hosted on the following CDNs:

* [**unpkg**](https://unpkg.com/prop-types/)
Expand All @@ -44,7 +44,7 @@ single-file distributions, which are hosted on the following CDNs:
<script src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.6.0/prop-types.min.js"></script>
```

To load a specific version of `prop-types` replace `15.6.0` with the version number.
To load a specific version of `prop-types` replace `15.6.0` with the version number.

## Usage

Expand All @@ -67,6 +67,7 @@ MyComponent.propTypes = {
// You can declare that a prop is a specific JS primitive. By default, these
// are all optional.
optionalArray: PropTypes.array,
optionalBigInt: PropTypes.bigint,
optionalBool: PropTypes.bool,
optionalFunc: PropTypes.func,
optionalNumber: PropTypes.number,
Expand All @@ -76,11 +77,17 @@ MyComponent.propTypes = {

// Anything that can be rendered: numbers, strings, elements or an array
// (or fragment) containing these types.
// see https://reactjs.org/docs/rendering-elements.html for more info
optionalNode: PropTypes.node,

// A React element.
// A React element (ie. <MyComponent />).
optionalElement: PropTypes.element,

// A React element type (eg. MyComponent).
// a function, string, or "element-like" object (eg. React.Fragment, Suspense, etc.)
// see https://github.com/facebook/react/blob/HEAD/packages/shared/isValidElementType.js
optionalElementType: PropTypes.elementType,

// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
optionalMessage: PropTypes.instanceOf(Message),
Expand All @@ -102,14 +109,21 @@ MyComponent.propTypes = {
// An object with property values of a certain type
optionalObjectOf: PropTypes.objectOf(PropTypes.number),

// You can chain any of the above with `isRequired` to make sure a warning
// is shown if the prop isn't provided.

// An object taking on a particular shape
optionalObjectWithShape: PropTypes.shape({
color: PropTypes.string,
fontSize: PropTypes.number
optionalProperty: PropTypes.string,
requiredProperty: PropTypes.number.isRequired
}),

// An object with warnings on extra properties
optionalObjectWithStrictShape: PropTypes.exact({
optionalProperty: PropTypes.string,
requiredProperty: PropTypes.number.isRequired
}),

// You can chain any of the above with `isRequired` to make sure a warning
// is shown if the prop isn't provided.
requiredFunc: PropTypes.func.isRequired,

// A value of any data type
Expand Down Expand Up @@ -160,18 +174,18 @@ For example:

```js
"dependencies": {
"prop-types": "^15.5.7"
"prop-types": "^15.5.7"
}
```

For libraries, we *also* recommend leaving it in `dependencies`:

```js
"dependencies": {
"prop-types": "^15.5.7"
"prop-types": "^15.5.7"
},
"peerDependencies": {
"react": "^15.5.0"
"react": "^15.5.0"
}
```

Expand All @@ -185,7 +199,7 @@ For UMD bundles of your components, make sure you **don’t** include `PropTypes

### React 0.14

This package is compatible with **React 0.14.9**. Compared to 0.14.8 (which was released a year ago), there are no other changes in 0.14.9, so it should be a painless upgrade.
This package is compatible with **React 0.14.9**. Compared to 0.14.8 (which was released in March of 2016), there are no other changes in 0.14.9, so it should be a painless upgrade.

```shell
# ATTENTION: Only run this if you still use React 0.14!
Expand Down Expand Up @@ -246,9 +260,11 @@ PropTypes.checkPropTypes(MyComponent.propTypes, props, 'prop', 'MyComponent');
```
See below for more info.

**If you DO want to use validation in production**, you can choose to use the **development version** by importing/requiring `prop-types/prop-types` instead of `prop-types`.

**You might also see this error** if you’re calling a `PropTypes` validator from your own custom `PropTypes` validator. In this case, the fix is to make sure that you are passing *all* of the arguments to the inner function. There is a more in-depth explanation of how to fix it [on this page](https://facebook.github.io/react/warnings/dont-call-proptypes.html#fixing-the-false-positive-in-third-party-proptypes). Alternatively, you can temporarily keep using `React.PropTypes` until React 16, as it would still only warn in this case.

If you use a bundler like Browserify or Webpack, don’t forget to [follow these instructions](https://facebook.github.io/react/docs/installation.html#development-and-production-versions) to correctly bundle your application in development or production mode. Otherwise you’ll ship unnecessary code to your users.
If you use a bundler like Browserify or Webpack, don’t forget to [follow these instructions](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) to correctly bundle your application in development or production mode. Otherwise you’ll ship unnecessary code to your users.

## PropTypes.checkPropTypes

Expand Down Expand Up @@ -276,3 +292,11 @@ PropTypes.checkPropTypes(myPropTypes, props, 'prop', 'MyComponent');
// Warning: Failed prop type: Invalid prop `age` of type `string` supplied to
// `MyComponent`, expected `number`.
```

## PropTypes.resetWarningCache()

`PropTypes.checkPropTypes(...)` only `console.error`s a given message once. To reset the error warning cache in tests, call `PropTypes.resetWarningCache()`

### License

prop-types is [MIT licensed](./LICENSE).
Loading
Loading