@@ -49,6 +49,7 @@ import {
4949 patch as patchConsole ,
5050 registerRenderer as registerRendererWithConsole ,
5151} from './console' ;
52+ import { isMemo , isForwardRef } from 'react-is' ;
5253
5354import type { Fiber } from 'react-reconciler/src/ReactFiber' ;
5455import type {
@@ -326,17 +327,28 @@ export function getInternalReactConstants(
326327 SCOPE_SYMBOL_STRING ,
327328 } = ReactSymbols ;
328329
330+ function resolveFiberType ( type : any ) {
331+ // This is to support lazy components with a Promise as the type.
332+ // see https://github.com/facebook/react/pull/13397
333+ if ( typeof type . then === 'function' ) {
334+ return type . _reactResult ;
335+ }
336+ if ( isMemo ( type ) ) {
337+ return resolveFiberType ( type . type ) ;
338+ }
339+ if ( isForwardRef ( type ) ) {
340+ return resolveFiberType ( type . render ) ;
341+ }
342+ return type ;
343+ }
344+
329345 // NOTICE Keep in sync with shouldFilterFiber() and other get*ForFiber methods
330346 function getDisplayNameForFiber ( fiber : Fiber ) : string | null {
331- const { type, tag} = fiber ;
347+ const { elementType , type, tag} = fiber ;
332348
333- // This is to support lazy components with a Promise as the type.
334- // see https://github.com/facebook/react/pull/13397
335349 let resolvedType = type ;
336350 if ( typeof type === 'object' && type !== null ) {
337- if ( typeof type . then === 'function' ) {
338- resolvedType = type . _reactResult ;
339- }
351+ resolvedType = resolveFiberType ( type ) ;
340352 }
341353
342354 let resolvedContext : any = null ;
@@ -348,8 +360,6 @@ export function getInternalReactConstants(
348360 case FunctionComponent :
349361 case IndeterminateComponent :
350362 return getDisplayName ( resolvedType ) ;
351- case MemoComponent :
352- case SimpleMemoComponent :
353363 case ForwardRef :
354364 return (
355365 resolvedType . displayName || getDisplayName ( resolvedType , 'Anonymous' )
@@ -362,6 +372,13 @@ export function getInternalReactConstants(
362372 case HostText :
363373 case Fragment :
364374 return null ;
375+ case MemoComponent :
376+ case SimpleMemoComponent :
377+ if ( elementType . displayName ) {
378+ return elementType . displayName ;
379+ } else {
380+ return getDisplayName ( resolvedType , 'Anonymous' ) ;
381+ }
365382 case SuspenseComponent :
366383 return 'Suspense' ;
367384 case SuspenseListComponent :
0 commit comments