Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #180 from jaller94/master
Browse files Browse the repository at this point in the history
Update README to include .exact()
  • Loading branch information
gaearon authored Jun 19, 2018
2 parents 2ac742c + 3c99d57 commit 5115f5c
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down Expand Up @@ -102,14 +102,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 +167,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 Down

0 comments on commit 5115f5c

Please sign in to comment.