@@ -4,6 +4,9 @@ import React from 'react'
44import PropTypes from 'prop-types'
55import matchPath from './matchPath'
66
7+ const isEmptyChildren = ( children ) =>
8+ React . Children . count ( children ) === 0
9+
710/**
811 * The public API for matching a single path and rendering.
912 */
@@ -66,20 +69,18 @@ class Route extends React.Component {
6669 }
6770
6871 componentWillMount ( ) {
69- const { component, render, children } = this . props
70-
7172 warning (
72- ! ( component && render ) ,
73+ ! ( this . props . component && this . props . render ) ,
7374 'You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored'
7475 )
7576
7677 warning (
77- ! ( component && children ) ,
78+ ! ( this . props . component && this . props . children && ! isEmptyChildren ( this . props . children ) ) ,
7879 'You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored'
7980 )
8081
8182 warning (
82- ! ( render && children ) ,
83+ ! ( this . props . render && this . props . children && ! isEmptyChildren ( this . props . children ) ) ,
8384 'You should not use <Route render> and <Route children> in the same route; <Route children> will be ignored'
8485 )
8586 }
@@ -115,7 +116,7 @@ class Route extends React.Component {
115116 ) : children ? ( // children come last, always called
116117 typeof children === 'function' ? (
117118 children ( props )
118- ) : ! Array . isArray ( children ) || children . length ? ( // Preact defaults to empty children array
119+ ) : ! isEmptyChildren ( children ) ? (
119120 React . Children . only ( children )
120121 ) : (
121122 null
0 commit comments