Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check propTypes ahead of time #3591

Merged
merged 1 commit into from
Jun 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions modules/RouteUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import warning from './routerWarning'

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

function checkPropTypes(componentName, propTypes, props) {
componentName = componentName || 'UnknownComponent'

for (const propName in propTypes) {
if (Object.prototype.hasOwnProperty.call(propTypes, propName)) {
const error = propTypes[propName](props, propName, componentName)

/* istanbul ignore if: error logging */
if (error instanceof Error)
warning(false, error.message)
}
}
}

function createRoute(defaultProps, props) {
return { ...defaultProps, ...props }
}
Expand All @@ -31,9 +16,6 @@ export function createRouteFromReactElement(element) {
const type = element.type
const route = createRoute(type.defaultProps, element.props)

if (type.propTypes)
checkPropTypes(type.displayName || type.name, type.propTypes, route)

if (route.children) {
const childRoutes = createRoutesFromReactChildren(route.children, route)

Expand All @@ -52,7 +34,7 @@ export function createRouteFromReactElement(element) {
* nested.
*
* import { Route, createRoutesFromReactChildren } from 'react-router'
*
*
* const routes = createRoutesFromReactChildren(
* <Route component={App}>
* <Route path="home" component={Dashboard}/>
Expand Down