@@ -621,7 +621,11 @@ export function inspectHooks<Props>(
621621 let ancestorStackError ;
622622 try {
623623 ancestorStackError = new Error ( ) ;
624- renderFunction ( props , legacyContext ) ;
624+ if ( legacyContext ) {
625+ renderFunction ( props , legacyContext ) ;
626+ } else {
627+ renderFunction ( props ) ;
628+ }
625629 } finally {
626630 readHookLog = hookLog ;
627631 hookLog = [ ] ;
@@ -745,16 +749,25 @@ export function inspectHooksOfFiber(
745749 currentHook = ( fiber . memoizedState : Hook ) ;
746750 const contextMap = new Map ( ) ;
747751 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 ) ;
750761 return inspectHooksOfForwardRef (
751762 type . render ,
752763 props ,
753764 fiber . ref ,
754765 currentDispatcher ,
755766 ) ;
767+ } else {
768+ setupContexts ( contextMap , fiber ) ;
769+ return inspectHooks ( type , props , currentDispatcher ) ;
756770 }
757- return inspectHooks ( type , props , currentDispatcher , legacyContext ) ;
758771 } finally {
759772 currentHook = null ;
760773 restoreContexts ( contextMap ) ;
0 commit comments