@@ -868,7 +868,12 @@ function findCommonAncestorIndex(rootStack: any, hookStack: any) {
868868}
869869
870870function isReactWrapper ( functionName : any , wrapperName : string ) {
871- return parseHookName ( functionName ) === wrapperName ;
871+ const hookName = parseHookName ( functionName ) ;
872+ if ( wrapperName === 'HostTransitionStatus' ) {
873+ return hookName === wrapperName || hookName === 'FormStatus' ;
874+ }
875+
876+ return hookName === wrapperName;
872877}
873878
874879function findPrimitiveIndex ( hookStack : any , hook : HookLogEntry ) {
@@ -878,21 +883,24 @@ function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
878883 return - 1 ;
879884 }
880885 for (let i = 0; i < primitiveStack . length && i < hookStack . length ; i ++ ) {
886+ // Note: there is no guarantee that we will find the top-most primitive frame in the stack
887+ // For React Native (uses Hermes), these source fields will be identical and skipped
881888 if ( primitiveStack [ i ] . source !== hookStack [ i ] . source ) {
882- // If the next frame is a method from the dispatcher, we
883- // assume that the next frame after that is the actual public API call.
884- // This prohibits nesting dispatcher calls in hooks.
889+ // If the next two frames are functions called `useX` then we assume that they're part of the
890+ // wrappers that the React package or other packages adds around the dispatcher.
891+ if (
892+ i < hookStack . length - 1 &&
893+ isReactWrapper ( hookStack [ i ] . functionName , hook . dispatcherHookName )
894+ ) {
895+ i ++ ;
896+ }
885897 if (
886898 i < hookStack . length - 1 &&
887899 isReactWrapper ( hookStack [ i ] . functionName , hook . dispatcherHookName )
888900 ) {
889901 i ++ ;
890- // Guard against the dispatcher call being inlined.
891- // At this point we wouldn't be able to recover the actual React Hook name.
892- if ( i < hookStack . length - 1 ) {
893- i ++ ;
894- }
895902 }
903+
896904 return i ;
897905 }
898906 }
@@ -1040,7 +1048,7 @@ function buildTree(
10401048 const levelChild: HooksNode = {
10411049 id ,
10421050 isStateEditable ,
1043- name : name ,
1051+ name ,
10441052 value : hook . value ,
10451053 subHooks : [ ] ,
10461054 debugInfo : debugInfo ,
0 commit comments