Skip to content

Commit 7a7c8c5

Browse files
committed
Add componentStack to ReactNativeInspector data
This is fairly lazy in that only the selected instance calls this so the slow component stack call is ok.
1 parent 6bb9cb4 commit 7a7c8c5

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

packages/react-native-renderer/src/ReactNativeFiberInspector.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
import {enableGetInspectorDataForInstanceInProduction} from 'shared/ReactFeatureFlags';
2525
import {getClosestInstanceFromNode} from './ReactNativeComponentTree';
2626
import {getNodeFromInternalInstanceHandle} from './ReactNativePublicCompat';
27+
import {getStackByFiberInDevAndProd} from 'react-reconciler/src/ReactFiberComponentStack';
2728

2829
const emptyObject = {};
2930
if (__DEV__) {
@@ -106,12 +107,14 @@ function getInspectorDataForInstance(
106107
const hierarchy = createHierarchy(fiberHierarchy);
107108
const props = getHostProps(instance);
108109
const selectedIndex = fiberHierarchy.indexOf(instance);
110+
const componentStack = getStackByFiberInDevAndProd(fiber);
109111

110112
return {
111113
closestInstance: instance,
112114
hierarchy,
113115
props,
114116
selectedIndex,
117+
componentStack,
115118
};
116119
}
117120

packages/react-native-renderer/src/ReactNativeTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export type InspectorData = $ReadOnly<{
159159
}>,
160160
selectedIndex: ?number,
161161
props: InspectorDataProps,
162+
componentStack: string,
162163
}>;
163164

164165
export type TouchedViewDataAtPoint = $ReadOnly<{

0 commit comments

Comments
 (0)