From facdc2f6f431645d68f423b157ecbdfae1ad9def Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Thu, 3 Jul 2025 09:34:58 -0700 Subject: [PATCH] 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 --- .../LogBox/__tests__/fantomHelpers.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/react-native/Libraries/LogBox/__tests__/fantomHelpers.js b/packages/react-native/Libraries/LogBox/__tests__/fantomHelpers.js index 65ee1795b0d..8a04a20c631 100644 --- a/packages/react-native/Libraries/LogBox/__tests__/fantomHelpers.js +++ b/packages/react-native/Libraries/LogBox/__tests__/fantomHelpers.js @@ -117,7 +117,7 @@ function findLogBoxInspectorUI(node: ReadOnlyElement): InspectorUI { // anonymous // MockConsoleErrorForTesting <-- mockConsoleIndex // ManualConsoleError -// reactStackBottomFrame <-- react bottom frame +// react_stack_bottom_frame <-- react bottom frame // // // Becomes: @@ -129,9 +129,19 @@ function getStackFrames(node: ReadOnlyElement): ?Array { 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); }