diff --git a/src/renderers/shared/fiber/ReactChildFiber.js b/src/renderers/shared/fiber/ReactChildFiber.js index 115134e6b9..1a8fc6a459 100644 --- a/src/renderers/shared/fiber/ReactChildFiber.js +++ b/src/renderers/shared/fiber/ReactChildFiber.js @@ -61,8 +61,10 @@ const { const isArray = Array.isArray; const { + FunctionalComponent, ClassComponent, HostText, + HostRoot, HostPortal, CoroutineComponent, YieldComponent, @@ -1197,6 +1199,25 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) { } } + if (typeof newChild === 'undefined') { + switch (returnFiber.tag) { + case HostRoot: + // TODO: Top-level render + break; + case ClassComponent: + case FunctionalComponent: { + const Component = returnFiber.type; + invariant( + false, + '%s: Nothing was returned from render. This usually means a ' + + 'return statement is missing. Or, to render nothing, ' + + 'return null.', + Component.displayName || Component.name || 'Component' + ); + } + } + } + // Remaining cases are all treated as empty. return deleteRemainingChildren(returnFiber, currentFirstChild); }