Skip to content
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