Files
react/packages/react-server/src/ReactFizzCallUserSpace.js
Ruslan Lesiutin 91d097b2c5 fix: rename bottom stack frame (#33680)
`react-stack-bottom-frame` -> `react_stack_bottom_frame`.

This survives `@babel/plugin-transform-function-name`, but now frames
will be displayed as `at Object.react_stack_bottom_frame (...)` in V8.
Checks that were relying on exact function name match were updated to
use either `.indexOf()` or `.includes()`

For backwards compatibility, both React DevTools and Flight Client will
look for both options. I am not so sure about the latter and if React
version is locked.
2025-07-01 18:06:26 +01:00

62 lines
1.8 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import type {LazyComponent} from 'react/src/ReactLazy';
// These indirections exists so we can exclude its stack frame in DEV (and anything below it).
// TODO: Consider marking the whole bundle instead of these boundaries.
const callComponent = {
react_stack_bottom_frame: function <Props, Arg, R>(
Component: (p: Props, arg: Arg) => R,
props: Props,
secondArg: Arg,
): R {
return Component(props, secondArg);
},
};
export const callComponentInDEV: <Props, Arg, R>(
Component: (p: Props, arg: Arg) => R,
props: Props,
secondArg: Arg,
) => R = __DEV__
? // We use this technique to trick minifiers to preserve the function name.
(callComponent.react_stack_bottom_frame.bind(callComponent): any)
: (null: any);
interface ClassInstance<R> {
render(): R;
}
const callRender = {
react_stack_bottom_frame: function <R>(instance: ClassInstance<R>): R {
return instance.render();
},
};
export const callRenderInDEV: <R>(instance: ClassInstance<R>) => R => R =
__DEV__
? // We use this technique to trick minifiers to preserve the function name.
(callRender.react_stack_bottom_frame.bind(callRender): any)
: (null: any);
const callLazyInit = {
react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
const payload = lazy._payload;
const init = lazy._init;
return init(payload);
},
};
export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
? // We use this technique to trick minifiers to preserve the function name.
(callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
: (null: any);