diff --git a/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js b/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js index 0c0b1d1a9273..10e95f7cf7ba 100644 --- a/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactEmptyComponent-test.js @@ -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(); - }).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(); - }).toThrowError('Empty(...): Nothing was returned from render.'); - }); }); diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index 3bef3545fc3a..e39660ba0b56 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -29,9 +29,7 @@ import { ClassComponent, HostText, HostPortal, - ForwardRef, Fragment, - SimpleMemoComponent, Block, } from './ReactWorkTags'; import invariant from 'shared/invariant'; @@ -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', ); } } diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index 6af9a6ab9fee..fc597b0a7d36 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -29,9 +29,7 @@ import { ClassComponent, HostText, HostPortal, - ForwardRef, Fragment, - SimpleMemoComponent, Block, } from './ReactWorkTags'; import invariant from 'shared/invariant'; @@ -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', ); } }