From d168b3362a61635578b703ff4b2bf70ea9ba7d53 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Thu, 3 Jul 2025 09:08:03 -0700 Subject: [PATCH] Support rename of React stack bottom frame Summary: # Changelog: [Internal] Adaptation for https://github.com/facebook/react/pull/33680. Reviewed By: jackpope Differential Revision: D77737710 --- .../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 65ee1795b0da..8a04a20c631f 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); }