Skip to content

Commit cb37dba

Browse files
committed
Add Example to README. Fixes issue #1.
1 parent 7abe4c9 commit cb37dba

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,37 @@
66
This is literally copied from the React 0.14 codebase.
77
If you're using PropTypes with React, it would be silly to reference this standalone version.
88

9-
**LICENSE:** BSD.
9+
10+
### Usage
11+
12+
```js
13+
function check(props, propTypes) {
14+
for (let prop in propTypes) {
15+
if (propTypes.hasOwnProperty(prop)) {
16+
let err = propTypes[prop](props, prop, 'name', 'prop');
17+
if (err) {
18+
console.warn(err);
19+
return false;
20+
}
21+
}
22+
}
23+
return true;
24+
}
25+
26+
let valid = check({
27+
a: 42,
28+
b: 'News'
29+
}, {
30+
a: PropTypes.number,
31+
b: PropTypes.oneOf(['News', 'Photos'])
32+
});
33+
34+
valid; // true
35+
```
36+
37+
38+
### License
39+
40+
BSD
1041

1142
[PropTypes]: https://github.com/facebook/react/blob/master/src/isomorphic/classic/types/ReactPropTypes.js

0 commit comments

Comments
 (0)