(hookStack: ParsedStackFrame[], hook: HookLogEntry)
| 903 | } |
| 904 | |
| 905 | function findPrimitiveIndex(hookStack: ParsedStackFrame[], hook: HookLogEntry) { |
| 906 | const stackCache = getPrimitiveStackCache(); |
| 907 | const primitiveStack = stackCache.get(hook.primitive); |
| 908 | if (primitiveStack === undefined) { |
| 909 | return -1; |
| 910 | } |
| 911 | for (let i = 0; i < primitiveStack.length && i < hookStack.length; i++) { |
| 912 | // Note: there is no guarantee that we will find the top-most primitive frame in the stack |
| 913 | // For React Native (uses Hermes), these source fields will be identical and skipped |
| 914 | if (primitiveStack[i].source !== hookStack[i].source) { |
| 915 | // If the next two frames are functions called `useX` then we assume that they're part of the |
| 916 | // wrappers that the React package or other packages adds around the dispatcher. |
| 917 | if ( |
| 918 | i < hookStack.length - 1 && |
| 919 | isReactWrapper(hookStack[i].functionName, hook.dispatcherHookName) |
| 920 | ) { |
| 921 | i++; |
| 922 | } |
| 923 | if ( |
| 924 | i < hookStack.length - 1 && |
| 925 | isReactWrapper(hookStack[i].functionName, hook.dispatcherHookName) |
| 926 | ) { |
| 927 | i++; |
| 928 | } |
| 929 | |
| 930 | return i; |
| 931 | } |
| 932 | } |
| 933 | return -1; |
| 934 | } |
| 935 | |
| 936 | function parseTrimmedStack(rootStack: ParsedStackFrame[], hook: HookLogEntry) { |
| 937 | // Get the stack trace between the primitive hook function and |
no test coverage detected