868
}
869
870
function 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;
877
}
878
879
function findPrimitiveIndex(hookStack: any, hook: HookLogEntry) {
883
return -1;
884
}
885
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
888
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
+ }
897
if (
898
i < hookStack.length - 1 &&
899
isReactWrapper(hookStack[i].functionName, hook.dispatcherHookName)
900
) {
901
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
- }
902
}
903
+
904
return i;
905
}
906
}
1048
const levelChild: HooksNode = {
1049
id,
1050
isStateEditable,
1043
- name: name,
1051
+ name,
1052
value: hook.value,
1053
subHooks: [],
1054
debugInfo: debugInfo,