mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Remove enableGetInspectorDataForInstanceInProduction flag (#32033)
## Summary
Callers for this method has been removed in
65bda54232,
so these methods no longer need to be conditionally exported and the
feature flag can be removed.
## How did you test this change?
Flow fabric/native
This commit is contained in:
@@ -29,7 +29,6 @@ import {
|
||||
import {createPortal as createPortalImpl} from 'react-reconciler/src/ReactPortal';
|
||||
import {setBatchingImplementation} from './legacy-events/ReactGenericBatching';
|
||||
|
||||
import {getInspectorDataForInstance} from './ReactNativeFiberInspector';
|
||||
import {LegacyRoot, ConcurrentRoot} from 'react-reconciler/src/ReactRootTags';
|
||||
import {
|
||||
findHostInstance_DEPRECATED,
|
||||
@@ -188,9 +187,6 @@ export {
|
||||
unmountComponentAtNode,
|
||||
stopSurface,
|
||||
createPortal,
|
||||
// This export is typically undefined in production builds.
|
||||
// See the "enableGetInspectorDataForInstanceInProduction" flag.
|
||||
getInspectorDataForInstance,
|
||||
// The public instance has a reference to the internal instance handle.
|
||||
// This method allows it to acess the most recent shadow node for
|
||||
// the instance (it's only accessible through it).
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
UIManager,
|
||||
getNodeFromPublicInstance,
|
||||
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
|
||||
import {enableGetInspectorDataForInstanceInProduction} from 'shared/ReactFeatureFlags';
|
||||
import {getClosestInstanceFromNode} from './ReactNativeComponentTree';
|
||||
import {
|
||||
getNodeFromInternalInstanceHandle,
|
||||
@@ -29,39 +28,40 @@ import {
|
||||
} from './ReactNativePublicCompat';
|
||||
import {getStackByFiberInDevAndProd} from 'react-reconciler/src/ReactFiberComponentStack';
|
||||
|
||||
const emptyObject = {};
|
||||
let getInspectorDataForInstance: (
|
||||
closestInstance: Fiber | null,
|
||||
) => InspectorData;
|
||||
|
||||
if (__DEV__) {
|
||||
Object.freeze(emptyObject);
|
||||
}
|
||||
const emptyObject = Object.freeze({});
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
function createHierarchy(fiberHierarchy) {
|
||||
return fiberHierarchy.map(fiber => ({
|
||||
name: getComponentNameFromType(fiber.type),
|
||||
getInspectorData: () => {
|
||||
return {
|
||||
props: getHostProps(fiber),
|
||||
measure: callback => {
|
||||
// If this is Fabric, we'll find a shadow node and use that to measure.
|
||||
const hostFiber = findCurrentHostFiber(fiber);
|
||||
const node =
|
||||
hostFiber != null &&
|
||||
hostFiber.stateNode !== null &&
|
||||
hostFiber.stateNode.node;
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
const createHierarchy = function (fiberHierarchy) {
|
||||
return fiberHierarchy.map(fiber => ({
|
||||
name: getComponentNameFromType(fiber.type),
|
||||
getInspectorData: () => {
|
||||
return {
|
||||
props: getHostProps(fiber),
|
||||
measure: callback => {
|
||||
// If this is Fabric, we'll find a shadow node and use that to measure.
|
||||
const hostFiber = findCurrentHostFiber(fiber);
|
||||
const node =
|
||||
hostFiber != null &&
|
||||
hostFiber.stateNode !== null &&
|
||||
hostFiber.stateNode.node;
|
||||
|
||||
if (node) {
|
||||
nativeFabricUIManager.measure(node, callback);
|
||||
} else {
|
||||
return UIManager.measure(getHostNode(fiber), callback);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
}));
|
||||
}
|
||||
if (node) {
|
||||
nativeFabricUIManager.measure(node, callback);
|
||||
} else {
|
||||
return UIManager.measure(getHostNode(fiber), callback);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
function getHostNode(fiber: Fiber | null) {
|
||||
if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
|
||||
const getHostNode = function (fiber: Fiber | null) {
|
||||
let hostNode;
|
||||
// look for children first for the hostNode
|
||||
// as composite fibers do not have a hostNode
|
||||
@@ -75,22 +75,19 @@ function getHostNode(fiber: Fiber | null) {
|
||||
fiber = fiber.child;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
function getHostProps(fiber) {
|
||||
const host = findCurrentHostFiber(fiber);
|
||||
if (host) {
|
||||
return host.memoizedProps || emptyObject;
|
||||
}
|
||||
return emptyObject;
|
||||
}
|
||||
const getHostProps = function (fiber: Fiber) {
|
||||
const host = findCurrentHostFiber(fiber);
|
||||
if (host) {
|
||||
return host.memoizedProps || emptyObject;
|
||||
}
|
||||
return emptyObject;
|
||||
};
|
||||
|
||||
function getInspectorDataForInstance(
|
||||
closestInstance: Fiber | null,
|
||||
): InspectorData {
|
||||
if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
|
||||
getInspectorDataForInstance = function (
|
||||
closestInstance: Fiber | null,
|
||||
): InspectorData {
|
||||
// Handle case where user clicks outside of ReactNative
|
||||
if (!closestInstance) {
|
||||
return {
|
||||
@@ -125,36 +122,30 @@ function getInspectorDataForInstance(
|
||||
selectedIndex,
|
||||
componentStack,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
throw new Error(
|
||||
'getInspectorDataForInstance() is not available in production',
|
||||
);
|
||||
}
|
||||
const getOwnerHierarchy = function (instance: Fiber) {
|
||||
const hierarchy: Array<$FlowFixMe> = [];
|
||||
traverseOwnerTreeUp(hierarchy, instance);
|
||||
return hierarchy;
|
||||
};
|
||||
|
||||
function getOwnerHierarchy(instance: Fiber) {
|
||||
const hierarchy: Array<$FlowFixMe> = [];
|
||||
traverseOwnerTreeUp(hierarchy, instance);
|
||||
return hierarchy;
|
||||
}
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
const lastNonHostInstance = function (hierarchy) {
|
||||
for (let i = hierarchy.length - 1; i > 1; i--) {
|
||||
const instance = hierarchy[i];
|
||||
|
||||
// $FlowFixMe[missing-local-annot]
|
||||
function lastNonHostInstance(hierarchy) {
|
||||
for (let i = hierarchy.length - 1; i > 1; i--) {
|
||||
const instance = hierarchy[i];
|
||||
|
||||
if (instance.tag !== HostComponent) {
|
||||
return instance;
|
||||
if (instance.tag !== HostComponent) {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hierarchy[0];
|
||||
}
|
||||
return hierarchy[0];
|
||||
};
|
||||
|
||||
function traverseOwnerTreeUp(
|
||||
hierarchy: Array<$FlowFixMe>,
|
||||
instance: Fiber,
|
||||
): void {
|
||||
if (__DEV__ || enableGetInspectorDataForInstanceInProduction) {
|
||||
const traverseOwnerTreeUp = function (
|
||||
hierarchy: Array<$FlowFixMe>,
|
||||
instance: Fiber,
|
||||
): void {
|
||||
hierarchy.unshift(instance);
|
||||
const owner = instance._debugOwner;
|
||||
if (owner != null && typeof owner.tag === 'number') {
|
||||
@@ -162,13 +153,12 @@ function traverseOwnerTreeUp(
|
||||
} else {
|
||||
// TODO: Traverse Server Components owners.
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getInspectorDataForViewTag(viewTag: number): InspectorData {
|
||||
if (__DEV__) {
|
||||
const closestInstance = getClosestInstanceFromNode(viewTag);
|
||||
|
||||
return getInspectorDataForInstance(closestInstance);
|
||||
} else {
|
||||
throw new Error(
|
||||
|
||||
@@ -34,7 +34,6 @@ import {
|
||||
// Modules provided by RN:
|
||||
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
|
||||
|
||||
import {getInspectorDataForInstance} from './ReactNativeFiberInspector';
|
||||
import {LegacyRoot} from 'react-reconciler/src/ReactRootTags';
|
||||
import {
|
||||
findHostInstance_DEPRECATED,
|
||||
@@ -206,9 +205,6 @@ export {
|
||||
unmountComponentAtNodeAndRemoveContainer,
|
||||
createPortal,
|
||||
batchedUpdates as unstable_batchedUpdates,
|
||||
// This export is typically undefined in production builds.
|
||||
// See the "enableGetInspectorDataForInstanceInProduction" flag.
|
||||
getInspectorDataForInstance,
|
||||
// DEV-only:
|
||||
isChildPublicInstance,
|
||||
};
|
||||
|
||||
@@ -260,6 +260,4 @@ export const enableAsyncDebugInfo = __EXPERIMENTAL__;
|
||||
export const enableUpdaterTracking = __PROFILE__;
|
||||
|
||||
// Internal only.
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
|
||||
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
|
||||
|
||||
@@ -48,7 +48,6 @@ export const enableCreateEventHandleAPI = false;
|
||||
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
|
||||
export const enableMoveBefore = true;
|
||||
export const enableFizzExternalRuntime = true;
|
||||
export const enableGetInspectorDataForInstanceInProduction = true;
|
||||
export const enableHalt = false;
|
||||
export const enableInfiniteRenderLoopDetection = false;
|
||||
export const enableLegacyCache = false;
|
||||
|
||||
@@ -33,7 +33,6 @@ export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
|
||||
export const enableFabricCompleteRootInCommitPhase = false;
|
||||
export const enableMoveBefore = true;
|
||||
export const enableFizzExternalRuntime = true;
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
export const enableHalt = false;
|
||||
export const enableHiddenSubtreeInsertionEffectCleanup = false;
|
||||
export const enableInfiniteRenderLoopDetection = false;
|
||||
|
||||
@@ -36,7 +36,6 @@ export const enableUseEffectEventHook = false;
|
||||
export const favorSafetyOverHydrationPerf = true;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableMoveBefore = false;
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
export const enableFabricCompleteRootInCommitPhase = false;
|
||||
export const enableHiddenSubtreeInsertionEffectCleanup = false;
|
||||
export const enableHydrationLaneScheduling = true;
|
||||
|
||||
@@ -27,7 +27,6 @@ export const enableCreateEventHandleAPI = false;
|
||||
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
|
||||
export const enableMoveBefore = false;
|
||||
export const enableFizzExternalRuntime = true;
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
export const enableHalt = false;
|
||||
export const enableInfiniteRenderLoopDetection = false;
|
||||
export const enableHiddenSubtreeInsertionEffectCleanup = true;
|
||||
|
||||
@@ -38,7 +38,6 @@ export const enableUseEffectEventHook = false;
|
||||
export const favorSafetyOverHydrationPerf = true;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableMoveBefore = false;
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
export const enableRenderableContext = false;
|
||||
export const enableFabricCompleteRootInCommitPhase = false;
|
||||
export const enableHiddenSubtreeInsertionEffectCleanup = true;
|
||||
|
||||
@@ -69,7 +69,6 @@ export const enableSchedulingProfiler: boolean =
|
||||
__PROFILE__ && dynamicFeatureFlags.enableSchedulingProfiler;
|
||||
|
||||
export const disableLegacyContext = __EXPERIMENTAL__;
|
||||
export const enableGetInspectorDataForInstanceInProduction = false;
|
||||
|
||||
export const enableLegacyCache = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user