@@ -1189,8 +1189,10 @@ 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 = '(...)' ;
11921193 switch ( returnFiber . tag ) {
11931194 case ClassComponent : {
1195+ componentNameSuffix = '.render()' ;
11941196 if ( __DEV__ ) {
11951197 const instance = returnFiber . stateNode ;
11961198 if ( instance . render . _isMockFunction && typeof newChild === 'undefined' ) {
@@ -1199,27 +1201,21 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
11991201 break ;
12001202 }
12011203 }
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 ;
12111204 }
1205+ // Intentionally fall through to the next case, which handles both
1206+ // functions and classes
1207+ // eslint-disable-next-lined no-fallthrough
12121208 case FunctionalComponent : {
12131209 // Composites accept elements, portals, null, or false
12141210 const Component = returnFiber . type ;
12151211 invariant (
12161212 newChild === null || newChild === false ,
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.' ,
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.' ,
12201216 Component . displayName || Component . name || 'Component' ,
1217+ componentNameSuffix
12211218 ) ;
1222- break ;
12231219 }
12241220 }
12251221 }
0 commit comments