mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
315109b02b
Stacked on #30142. This tracks owners and their stacks in DEV in Fizz. We use the ComponentStackNode as the data structure to track this information - effectively like ReactComponentInfo (Server) or Fiber (Client). They're the instance. I then port them same logic from ReactFiberComponentStack, ReactFiberOwnerStack and ReactFiberCallUserSpace to Fizz equivalents. This gets us both owner stacks from `captureOwnerStack()`, as well as appended to console.errors logged by Fizz, while rendering and in onError.
37 lines
958 B
JavaScript
37 lines
958 B
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 {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';
|
|
import type {ComponentStackNode} from './ReactFizzComponentStack';
|
|
|
|
import {disableStringRefs} from 'shared/ReactFeatureFlags';
|
|
|
|
import {currentTaskInDEV} from './ReactFizzCurrentTask';
|
|
|
|
function getCacheForType<T>(resourceType: () => T): T {
|
|
throw new Error('Not implemented.');
|
|
}
|
|
|
|
export const DefaultAsyncDispatcher: AsyncDispatcher = ({
|
|
getCacheForType,
|
|
}: any);
|
|
|
|
if (__DEV__) {
|
|
DefaultAsyncDispatcher.getOwner = (): ComponentStackNode | null => {
|
|
if (currentTaskInDEV === null) {
|
|
return null;
|
|
}
|
|
return currentTaskInDEV.componentStack;
|
|
};
|
|
} else if (!disableStringRefs) {
|
|
DefaultAsyncDispatcher.getOwner = (): null => {
|
|
return null;
|
|
};
|
|
}
|