@@ -1189,10 +1189,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
11891189 if ( disableNewFiberFeatures ) {
11901190 // The new child is not an element. If it's not null or false,
11911191 // and the return fiber is a composite component, throw an error.
1192- let componentNameSuffix = '(...)' ;
11931192 switch ( returnFiber . tag ) {
11941193 case ClassComponent : {
1195- componentNameSuffix = '.render()' ;
11961194 if ( __DEV__ ) {
11971195 const instance = returnFiber . stateNode ;
11981196 if ( instance . render . _isMockFunction && typeof newChild === 'undefined' ) {
@@ -1201,21 +1199,27 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
12011199 break ;
12021200 }
12031201 }
1202+ const Component = returnFiber . type ;
1203+ invariant (
1204+ newChild === null || newChild === false ,
1205+ '%s.render(): A valid React element (or null) must be returned. ' +
1206+ 'You may have returned undefined, an array or some other ' +
1207+ 'invalid object.' ,
1208+ Component . displayName || Component . name || 'Component' ,
1209+ ) ;
1210+ break ;
12041211 }
1205- // Intentionally fall through to the next case, which handles both
1206- // functions and classes
1207- // eslint-disable-next-lined no-fallthrough
12081212 case FunctionalComponent : {
12091213 // Composites accept elements, portals, null, or false
12101214 const Component = returnFiber . type ;
12111215 invariant (
12121216 newChild === null || newChild === false ,
1213- '%s%s : A valid React element (or null) must be ' +
1214- 'returned. You may have returned undefined, an array or some ' +
1215- 'other invalid object.' ,
1217+ '%s(...) : A valid React element (or null) must be returned. ' +
1218+ 'You may have returned undefined, an array or some other ' +
1219+ 'invalid object.' ,
12161220 Component . displayName || Component . name || 'Component' ,
1217- componentNameSuffix
12181221 ) ;
1222+ break ;
12191223 }
12201224 }
12211225 }
0 commit comments