@@ -621,7 +621,11 @@ export function inspectHooks<Props>(
621
621
let ancestorStackError ;
622
622
try {
623
623
ancestorStackError = new Error ( ) ;
624
- renderFunction ( props , legacyContext ) ;
624
+ if ( legacyContext && legacyContext !== null ) {
625
+ renderFunction ( props , legacyContext ) ;
626
+ } else {
627
+ renderFunction ( props ) ;
628
+ }
625
629
} finally {
626
630
readHookLog = hookLog ;
627
631
hookLog = [ ] ;
@@ -745,16 +749,25 @@ export function inspectHooksOfFiber(
745
749
currentHook = ( fiber . memoizedState : Hook ) ;
746
750
const contextMap = new Map ( ) ;
747
751
try {
748
- const legacyContext = setupContexts ( contextMap , fiber , enableLegacyContext ) ;
749
- if ( fiber . tag === ForwardRef ) {
752
+ if ( fiber . tag === FunctionComponent ) {
753
+ const legacyContext = setupContexts (
754
+ contextMap ,
755
+ fiber ,
756
+ enableLegacyContext ,
757
+ ) ;
758
+ return inspectHooks ( type , props , currentDispatcher , legacyContext ) ;
759
+ } else if ( fiber . tag === ForwardRef ) {
760
+ setupContexts ( contextMap , fiber ) ;
750
761
return inspectHooksOfForwardRef (
751
762
type . render ,
752
763
props ,
753
764
fiber . ref ,
754
765
currentDispatcher ,
755
766
) ;
767
+ } else {
768
+ setupContexts ( contextMap , fiber ) ;
769
+ return inspectHooks ( type , props , currentDispatcher ) ;
756
770
}
757
- return inspectHooks ( type , props , currentDispatcher , legacyContext ) ;
758
771
} finally {
759
772
currentHook = null ;
760
773
restoreContexts ( contextMap ) ;
0 commit comments