File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 66This is literally copied from the React 0.14 codebase.
77If 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
You can’t perform that action at this time.
0 commit comments