1
1
/* jshint -W084 */
2
2
var React = require ( 'react' ) ;
3
- var warning = require ( 'react/lib/warning' ) ;
4
3
var invariant = require ( 'react/lib/invariant' ) ;
5
4
var DefaultRoute = require ( './components/DefaultRoute' ) ;
6
5
var NotFoundRoute = require ( './components/NotFoundRoute' ) ;
@@ -21,28 +20,17 @@ function createRedirectHandler(to, _params, _query) {
21
20
} ) ;
22
21
}
23
22
24
- function checkPropTypes ( componentName , propTypes , props ) {
25
- for ( var propName in propTypes ) {
26
- if ( propTypes . hasOwnProperty ( propName ) ) {
27
- var error = propTypes [ propName ] ( props , propName , componentName ) ;
28
-
29
- if ( error instanceof Error )
30
- warning ( false , error . message ) ;
31
- }
32
- }
33
- }
34
-
35
23
function createRoute ( element , parentRoute , namedRoutes ) {
36
24
var type = element . type ;
37
25
var props = element . props ;
38
26
39
- if ( type . propTypes )
40
- checkPropTypes ( type . displayName , type . propTypes , props ) ;
41
-
42
- var route = { name : props . name } ;
27
+ if ( type . validateProps )
28
+ type . validateProps ( props ) ;
43
29
44
- if ( props . ignoreScrollBehavior )
45
- route . ignoreScrollBehavior = true ;
30
+ var route = {
31
+ name : props . name ,
32
+ ignoreScrollBehavior : ! ! props . ignoreScrollBehavior
33
+ } ;
46
34
47
35
if ( type === Redirect . type ) {
48
36
route . handler = createRedirectHandler ( props . to , props . params , props . query ) ;
0 commit comments