1- import React , { cloneElement } from 'react' ;
1+ import React , { cloneElement , PropTypes } from 'react' ;
22import Interpolate from './Interpolate' ;
33import BootstrapMixin from './BootstrapMixin' ;
44import classNames from 'classnames' ;
@@ -7,13 +7,14 @@ import ValidComponentChildren from './utils/ValidComponentChildren';
77
88const ProgressBar = React . createClass ( {
99 propTypes : {
10- min : React . PropTypes . number ,
11- now : React . PropTypes . number ,
12- max : React . PropTypes . number ,
13- label : React . PropTypes . node ,
14- srOnly : React . PropTypes . bool ,
15- striped : React . PropTypes . bool ,
16- active : React . PropTypes . bool
10+ min : PropTypes . number ,
11+ now : PropTypes . number ,
12+ max : PropTypes . number ,
13+ label : PropTypes . node ,
14+ srOnly : PropTypes . bool ,
15+ striped : PropTypes . bool ,
16+ active : PropTypes . bool ,
17+ children : onlyProgressBar
1718 } ,
1819
1920 mixins : [ BootstrapMixin ] ,
@@ -127,4 +128,22 @@ const ProgressBar = React.createClass({
127128 }
128129} ) ;
129130
131+ /**
132+ * Custom propTypes checker
133+ */
134+ function onlyProgressBar ( props , propName , componentName ) {
135+ if ( props [ propName ] ) {
136+ let error , childIdentifier ;
137+
138+ React . Children . forEach ( props [ propName ] , ( child ) => {
139+ if ( child . type !== ProgressBar ) {
140+ childIdentifier = ( child . type . displayName ? child . type . displayName : child . type ) ;
141+ error = new Error ( `Children of ${ componentName } can contain only ProgressBar components. Found ${ childIdentifier } ` ) ;
142+ }
143+ } ) ;
144+
145+ return error ;
146+ }
147+ }
148+
130149export default ProgressBar ;
0 commit comments