File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
react-devtools-shared/src/backend Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ import {
49
49
patch as patchConsole ,
50
50
registerRenderer as registerRendererWithConsole ,
51
51
} from './console' ;
52
- import { isMemo , isForwardRef } from 'react-is' ;
53
52
54
53
import type { Fiber } from 'react-reconciler/src/ReactFiber' ;
55
54
import type {
@@ -325,6 +324,10 @@ export function getInternalReactConstants(
325
324
PROFILER_SYMBOL_STRING ,
326
325
SCOPE_NUMBER ,
327
326
SCOPE_SYMBOL_STRING ,
327
+ FORWARD_REF_NUMBER ,
328
+ FORWARD_REF_SYMBOL_STRING ,
329
+ MEMO_NUMBER ,
330
+ MEMO_SYMBOL_STRING ,
328
331
} = ReactSymbols ;
329
332
330
333
function resolveFiberType ( type : any ) {
@@ -333,14 +336,18 @@ export function getInternalReactConstants(
333
336
if ( typeof type . then === 'function' ) {
334
337
return type . _reactResult ;
335
338
}
336
- if ( isForwardRef ( type ) ) {
337
- return type . render ;
338
- }
339
- // recursively resolving memo type in case of memo(forwardRef(Component))
340
- if ( isMemo ( type ) ) {
341
- return resolveFiberType ( type . type ) ;
339
+ const typeSymbol = getTypeSymbol ( type ) ;
340
+ switch ( typeSymbol ) {
341
+ case MEMO_NUMBER :
342
+ case MEMO_SYMBOL_STRING :
343
+ // recursively resolving memo type in case of memo(forwardRef(Component))
344
+ return resolveFiberType ( type . type ) ;
345
+ case FORWARD_REF_NUMBER :
346
+ case FORWARD_REF_SYMBOL_STRING :
347
+ return type . render ;
348
+ default :
349
+ return type ;
342
350
}
343
- return type ;
344
351
}
345
352
346
353
// NOTICE Keep in sync with shouldFilterFiber() and other get*ForFiber methods
Original file line number Diff line number Diff line change @@ -110,7 +110,6 @@ describe('ReactIs', () => {
110
110
const RefForwardingComponent = React . forwardRef ( ( props , ref ) => null ) ;
111
111
expect ( ReactIs . isValidElementType ( RefForwardingComponent ) ) . toBe ( true ) ;
112
112
expect ( ReactIs . typeOf ( < RefForwardingComponent /> ) ) . toBe ( ReactIs . ForwardRef ) ;
113
- expect ( ReactIs . isForwardRef ( RefForwardingComponent ) ) . toBe ( true ) ;
114
113
expect ( ReactIs . isForwardRef ( < RefForwardingComponent /> ) ) . toBe ( true ) ;
115
114
expect ( ReactIs . isForwardRef ( { type : ReactIs . StrictMode } ) ) . toBe ( false ) ;
116
115
expect ( ReactIs . isForwardRef ( < div /> ) ) . toBe ( false ) ;
You can’t perform that action at this time.
0 commit comments