Skip to content

Commit

Permalink
Revert "Warn about undefined return value for memo and forwardRef (#1…
Browse files Browse the repository at this point in the history
…9550)"

This reverts commit a63893f.
  • Loading branch information
gaearon committed Aug 10, 2020
1 parent 2704bb5 commit 18fde8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
20 changes: 0 additions & 20 deletions packages/react-dom/src/__tests__/ReactEmptyComponent-test.js
Expand Up @@ -316,24 +316,4 @@ describe('ReactEmptyComponent', () => {
const noscript2 = container.firstChild;
expect(noscript2).toBe(null);
});

it('should warn about React.forwardRef that returns undefined', () => {
const Empty = () => {};
const EmptyForwardRef = React.forwardRef(Empty);

expect(() => {
ReactTestUtils.renderIntoDocument(<EmptyForwardRef />);
}).toThrowError(
'ForwardRef(Empty)(...): Nothing was returned from render.',
);
});

it('should warn about React.memo that returns undefined', () => {
const Empty = () => {};
const EmptyMemo = React.memo(Empty);

expect(() => {
ReactTestUtils.renderIntoDocument(<EmptyMemo />);
}).toThrowError('Empty(...): Nothing was returned from render.');
});
});
10 changes: 3 additions & 7 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Expand Up @@ -29,9 +29,7 @@ import {
ClassComponent,
HostText,
HostPortal,
ForwardRef,
Fragment,
SimpleMemoComponent,
Block,
} from './ReactWorkTags';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -1395,16 +1393,14 @@ function ChildReconciler(shouldTrackSideEffects) {
// Intentionally fall through to the next case, which handles both
// functions and classes
// eslint-disable-next-lined no-fallthrough
case Block:
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent: {
case FunctionComponent: {
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.',
getComponentName(returnFiber.type) || 'Component',
Component.displayName || Component.name || 'Component',
);
}
}
Expand Down
10 changes: 3 additions & 7 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Expand Up @@ -29,9 +29,7 @@ import {
ClassComponent,
HostText,
HostPortal,
ForwardRef,
Fragment,
SimpleMemoComponent,
Block,
} from './ReactWorkTags';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -1387,16 +1385,14 @@ function ChildReconciler(shouldTrackSideEffects) {
// Intentionally fall through to the next case, which handles both
// functions and classes
// eslint-disable-next-lined no-fallthrough
case Block:
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent: {
case FunctionComponent: {
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.',
getComponentName(returnFiber.type) || 'Component',
Component.displayName || Component.name || 'Component',
);
}
}
Expand Down

0 comments on commit 18fde8e

Please sign in to comment.