Skip to content

Commit 92824f6

Browse files
gaearontaion
authored andcommitted
Don't check propTypes ahead of time
1 parent 13f327b commit 92824f6

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

modules/RouteUtils.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import warning from './routerWarning'
32

43
function isValidChild(object) {
54
return object == null || React.isValidElement(object)
@@ -9,20 +8,6 @@ export function isReactChildren(object) {
98
return isValidChild(object) || (Array.isArray(object) && object.every(isValidChild))
109
}
1110

12-
function checkPropTypes(componentName, propTypes, props) {
13-
componentName = componentName || 'UnknownComponent'
14-
15-
for (const propName in propTypes) {
16-
if (Object.prototype.hasOwnProperty.call(propTypes, propName)) {
17-
const error = propTypes[propName](props, propName, componentName)
18-
19-
/* istanbul ignore if: error logging */
20-
if (error instanceof Error)
21-
warning(false, error.message)
22-
}
23-
}
24-
}
25-
2611
function createRoute(defaultProps, props) {
2712
return { ...defaultProps, ...props }
2813
}
@@ -31,9 +16,6 @@ export function createRouteFromReactElement(element) {
3116
const type = element.type
3217
const route = createRoute(type.defaultProps, element.props)
3318

34-
if (type.propTypes)
35-
checkPropTypes(type.displayName || type.name, type.propTypes, route)
36-
3719
if (route.children) {
3820
const childRoutes = createRoutesFromReactChildren(route.children, route)
3921

@@ -52,7 +34,7 @@ export function createRouteFromReactElement(element) {
5234
* nested.
5335
*
5436
* import { Route, createRoutesFromReactChildren } from 'react-router'
55-
*
37+
*
5638
* const routes = createRoutesFromReactChildren(
5739
* <Route component={App}>
5840
* <Route path="home" component={Dashboard}/>

0 commit comments

Comments
 (0)