Skip to content

Commit

Permalink
Throw if undefined is returned from a composite component
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Jan 12, 2017
1 parent 8628018 commit 204d3dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/renderers/shared/fiber/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const {
const isArray = Array.isArray;

const {
FunctionalComponent,
ClassComponent,
HostText,
HostRoot,
HostPortal,
CoroutineComponent,
YieldComponent,
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 204d3dd

Please sign in to comment.