Support rename of React stack bottom frame (#52398)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52398

# Changelog: [Internal]

Adaptation for https://github.com/facebook/react/pull/33680.

Reviewed By: jackpope

Differential Revision: D77737710

fbshipit-source-id: 6c6893935e8da8175c0cd9ceab21cc05e2092e7a
This commit is contained in:
Ruslan Lesiutin
2025-07-03 09:34:58 -07:00
committed by Facebook GitHub Bot
parent 477d8df312
commit facdc2f6f4
@@ -117,7 +117,7 @@ function findLogBoxInspectorUI(node: ReadOnlyElement): InspectorUI {
// anonymous
// MockConsoleErrorForTesting <-- mockConsoleIndex
// ManualConsoleError
// reactStackBottomFrame <-- react bottom frame
// react_stack_bottom_frame <-- react bottom frame
// <root>
//
// Becomes:
@@ -129,9 +129,19 @@ function getStackFrames(node: ReadOnlyElement): ?Array<string> {
const mockConsoleIndex = text.includes('MockConsoleErrorForTesting')
? text.indexOf('MockConsoleErrorForTesting') + 1
: 0;
const bottomFrameIndex = text.includes('reactStackBottomFrame')
? text.indexOf('reactStackBottomFrame')
: text.length;
let bottomFrameIndex = text.indexOf('react_stack_bottom_frame');
if (bottomFrameIndex === -1) {
// react@19.1.0 with @babel/plugin-transform-function-name
bottomFrameIndex = text.indexOf('reactStackBottomFrame');
}
if (bottomFrameIndex === -1) {
// react@19.1.0 without @babel/plugin-transform-function-name
bottomFrameIndex = text.indexOf('react-stack-bottom-frame');
}
if (bottomFrameIndex === -1) {
bottomFrameIndex = text.length;
}
return text.slice(mockConsoleIndex, bottomFrameIndex);
}