[react-devtools-facade] consolidate owner stack tools naming (#36871)
Instead of potential confusion coming from `stack` vs `branch`, we will use `getOwnerStackTrace` for the error-like stack trace and `getOwnerStack` for list of structured entities that represent owners.
Ruslan Lesiutin committed
Jun 25, 2026 at 09:57 UTC
3c3bcea37fae2f4ceaa18c6035faa5e6dd837ce6
3 files changed
+25
-25
packages/react-devtools-facade/src/DevToolsFacadeTools.js
+4
-4
@@ -63,8 +63,8 @@ export type Tools = {
63
pageSize?: number,
64
) => FindComponentsResult | ToolError,
65
getComponentSource: (uid: string) => ComponentSource | ToolError,
66
- getOwnersStack: (uid: string) => OwnersStack | ToolError,
67
- getOwnersBranch: (uid: string) => Array<OwnerEntry> | ToolError,
66
+ getOwnerStackTrace: (uid: string) => OwnersStack | ToolError,
67
+ getOwnerStack: (uid: string) => Array<OwnerEntry> | ToolError,
68
startProfiling: (traceName?: string) => StartProfilingResult | ToolError,
69
stopProfiling: () => StopProfilingResult | ToolError,
70
getTraceOverview: (traceName: string) => Array<TraceOverviewRow> | ToolError,
@@ -96,8 +96,8 @@ export function createTools(facade: Facade): Tools {
96
getComponentByUid: tree.getComponentByUid,
97
findComponents: tree.findComponents,
98
getComponentSource: tree.getComponentSource,
99
- getOwnersStack: tree.getOwnersStack,
100
- getOwnersBranch: tree.getOwnersBranch,
99
+ getOwnerStackTrace: tree.getOwnerStackTrace,
100
+ getOwnerStack: tree.getOwnerStack,
101
startProfiling: profiler.startProfiling,
102
stopProfiling: profiler.stopProfiling,
103
getTraceOverview: profiler.getTraceOverview,
packages/react-devtools-facade/src/DevToolsFacadeTreeTools.js
+6
-6
@@ -89,8 +89,8 @@ export type TreeTools = {
89
pageSize?: number,
90
) => FindComponentsResult | ToolError,
91
getComponentSource: (uid: string) => ComponentSource | ToolError,
92
- getOwnersStack: (uid: string) => OwnersStack | ToolError,
93
- getOwnersBranch: (uid: string) => Array<OwnerEntry> | ToolError,
92
+ getOwnerStackTrace: (uid: string) => OwnersStack | ToolError,
93
+ getOwnerStack: (uid: string) => Array<OwnerEntry> | ToolError,
94
// Shared with the profiler tools so component uids are consistent across all
95
// tools. Maps a fiber to its stable uid (assigning one on first encounter).
96
getUid: (fiber: Fiber) => string,
@@ -605,7 +605,7 @@ export function createTreeTools(
605
*
606
* @param uid - The component uid (e.g. "r5").
607
*/
608
- function getOwnersStack(uid: string): OwnersStack | ToolError {
608
+ function getOwnerStackTrace(uid: string): OwnersStack | ToolError {
609
const result = findFiberByUid(uid);
610
if (result.error != null) {
611
return {error: result.error};
@@ -631,7 +631,7 @@ export function createTreeTools(
631
*
632
* @param uid - The component uid (e.g. "r5").
633
*/
634
- function getOwnersBranch(uid: string): Array<OwnerEntry> | ToolError {
634
+ function getOwnerStack(uid: string): Array<OwnerEntry> | ToolError {
635
const result = findFiberByUid(uid);
636
if (result.error != null) {
637
return {error: result.error};
@@ -667,8 +667,8 @@ export function createTreeTools(
667
getComponentByUid,
668
findComponents,
669
getComponentSource,
670
- getOwnersStack,
671
- getOwnersBranch,
670
+ getOwnerStackTrace,
671
+ getOwnerStack,
672
getUid,
673
};
674
}
packages/react-devtools-facade/src/__tests__/DevToolsFacade-test.js
+15
-15
@@ -979,13 +979,13 @@ describe('react-devtools-facade', () => {
979
});
980
});
981
982
- describe('getOwnersStack', () => {
983
- let getOwnersStack;
982
+ describe('getOwnerStackTrace', () => {
983
+ let getOwnerStackTrace;
984
let getComponentTree;
985
986
beforeEach(() => {
987
const tools = createTools(facade);
988
- getOwnersStack = tools.getOwnersStack;
988
+ getOwnerStackTrace = tools.getOwnerStackTrace;
989
getComponentTree = tools.getComponentTree;
990
});
991
@@ -1007,7 +1007,7 @@ describe('react-devtools-facade', () => {
1007
const child = getComponentTree().find(n => n.name === 'Child');
1008
expect(child).toBeDefined();
1009
1010
- const result = getOwnersStack(child.uid);
1010
+ const result = getOwnerStackTrace(child.uid);
1011
expect(typeof result.stack).toBe('string');
1012
// The stack should mention the owner components
1013
expect(result.stack).toContain('Parent');
@@ -1024,23 +1024,23 @@ describe('react-devtools-facade', () => {
1024
});
1025
1026
const app = getComponentTree().find(n => n.name === 'App');
1027
- const result = getOwnersStack(app.uid);
1027
+ const result = getOwnerStackTrace(app.uid);
1028
expect(typeof result.stack).toBe('string');
1029
});
1030
1031
it('returns error for non-existent uid', () => {
1032
- const result = getOwnersStack('r9999');
1032
+ const result = getOwnerStackTrace('r9999');
1033
expect(result.error).toMatch(/Component not found/);
1034
});
1035
});
1036
1037
- describe('getOwnersBranch', () => {
1038
- let getOwnersBranch;
1037
+ describe('getOwnerStack', () => {
1038
+ let getOwnerStack;
1039
let getComponentTree;
1040
1041
beforeEach(() => {
1042
const tools = createTools(facade);
1043
- getOwnersBranch = tools.getOwnersBranch;
1043
+ getOwnerStack = tools.getOwnerStack;
1044
getComponentTree = tools.getComponentTree;
1045
});
1046
@@ -1062,7 +1062,7 @@ describe('react-devtools-facade', () => {
1062
const child = getComponentTree().find(n => n.name === 'Child');
1063
expect(child).toBeDefined();
1064
1065
- const owners = getOwnersBranch(child.uid);
1065
+ const owners = getOwnerStack(child.uid);
1066
expect(owners).toEqual([
1067
{
1068
uid: 'r2',
@@ -1090,7 +1090,7 @@ describe('react-devtools-facade', () => {
1090
});
1091
1092
const child = getComponentTree().find(n => n.name === 'Child');
1093
- const owners = getOwnersBranch(child.uid);
1093
+ const owners = getOwnerStack(child.uid);
1094
1095
expect(owners).toHaveLength(1);
1096
expect(owners[0].uid).toBe('r0');
@@ -1114,7 +1114,7 @@ describe('react-devtools-facade', () => {
1114
const child = tree.find(n => n.name === 'Child');
1115
const app = tree.find(n => n.name === 'App');
1116
1117
- const owners = getOwnersBranch(child.uid);
1117
+ const owners = getOwnerStack(child.uid);
1118
expect(owners[0].uid).toBe(app.uid);
1119
});
1120
@@ -1128,12 +1128,12 @@ describe('react-devtools-facade', () => {
1128
});
1129
1130
const app = getComponentTree().find(n => n.name === 'App');
1131
- const owners = getOwnersBranch(app.uid);
1131
+ const owners = getOwnerStack(app.uid);
1132
expect(owners).toEqual([]);
1133
});
1134
1135
it('returns error for non-existent uid', () => {
1136
- const result = getOwnersBranch('r9999');
1136
+ const result = getOwnerStack('r9999');
1137
expect(result.error).toMatch(/Component not found/);
1138
});
1139
@@ -1156,7 +1156,7 @@ describe('react-devtools-facade', () => {
1156
});
1157
1158
const gc = getComponentTree().find(n => n.name === 'GrandChild');
1159
- const owners = getOwnersBranch(gc.uid);
1159
+ const owners = getOwnerStack(gc.uid);
1160
expect(owners).toEqual([
1161
{
1162
uid: 'r3',