mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
fix[rdt/fiber/renderer.js]: getCurrentFiber can be injected as null (#30968)
In production artifacts for `18.x.x` `getCurrentFiber` can actually be injected as `null`. Updated `getComponentStack` and `onErrorOrWarning` implementations to support this. 
This commit is contained in:
@@ -1078,7 +1078,7 @@ export function attach(
|
||||
function getComponentStack(
|
||||
topFrame: Error,
|
||||
): null | {enableOwnerStacks: boolean, componentStack: string} {
|
||||
if (getCurrentFiber === undefined) {
|
||||
if (getCurrentFiber == null) {
|
||||
// Expected this to be part of the renderer. Ignore.
|
||||
return null;
|
||||
}
|
||||
@@ -1130,7 +1130,7 @@ export function attach(
|
||||
type: 'error' | 'warn',
|
||||
args: $ReadOnlyArray<any>,
|
||||
): void {
|
||||
if (getCurrentFiber === undefined) {
|
||||
if (getCurrentFiber == null) {
|
||||
// Expected this to be part of the renderer. Ignore.
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ export type ReactRenderer = {
|
||||
currentDispatcherRef?: LegacyDispatcherRef | CurrentDispatcherRef,
|
||||
// Only injected by React v16.9+ in DEV mode.
|
||||
// Enables DevTools to append owners-only component stack to error messages.
|
||||
getCurrentFiber?: () => Fiber | null,
|
||||
getCurrentFiber?: (() => Fiber | null) | null,
|
||||
// Only injected by React Flight Clients in DEV mode.
|
||||
// Enables DevTools to append owners-only component stack to error messages from Server Components.
|
||||
getCurrentComponentInfo?: () => ReactComponentInfo | null,
|
||||
|
||||
Reference in New Issue
Block a user