Skip to content

Commit 70a5d6f

Browse files
rubennortefacebook-github-bot
authored andcommitted
Prepare for next React Native sync with new instance format (v2)
Summary: We made some changes to the new instance format, so need to adapt this again after D43980374. The previous format was never synced so we don't need to keep compatibility. Changelog: [internal] Reviewed By: javache Differential Revision: D44137324 fbshipit-source-id: bb08141674e2385934772f241acb863f9050b671
1 parent d92cfd5 commit 70a5d6f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ interface Agent {
3333
removeListener(event: $Keys<AgentEvents>, listener: () => void): void;
3434
}
3535

36-
type TraceNode = {
37-
publicInstance?: TraceNode,
38-
// TODO: remove this field when syncing the new version of the renderer from React to React Native.
39-
canonical?: TraceNode,
36+
type PublicInstance = {
4037
measure?: (
4138
(
4239
x: number,
@@ -49,6 +46,16 @@ type TraceNode = {
4946
) => void,
5047
};
5148

49+
type TraceNode =
50+
| PublicInstance
51+
| {
52+
canonical?:
53+
| PublicInstance // TODO: remove this variant when syncing the new version of the renderer from React to React Native.
54+
| {
55+
publicInstance?: PublicInstance,
56+
},
57+
};
58+
5259
type ReactDevToolsGlobalHook = {
5360
on: (eventName: string, (agent: Agent) => void) => void,
5461
off: (eventName: string, (agent: Agent) => void) => void,
@@ -102,11 +109,14 @@ export default function TraceUpdateOverlay(): React.Node {
102109

103110
const newFramesToDraw: Array<Promise<Overlay>> = [];
104111
nodesToDraw.forEach(({node, color}) => {
105-
// `publicInstance` => Fabric
112+
// `canonical.publicInstance` => Fabric
106113
// TODO: remove this check when syncing the new version of the renderer from React to React Native.
107114
// `canonical` => Legacy Fabric
108115
// `node` => Legacy renderer
109-
const component = node.publicInstance ?? node.canonical ?? node;
116+
const component =
117+
(node.canonical && node.canonical.publicInstance) ??
118+
node.canonical ??
119+
node;
110120
if (!component || !component.measure) {
111121
return;
112122
}

packages/react-native/Libraries/Inspector/DevtoolsOverlay.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ export default function DevtoolsOverlay({
5252
function onAgentShowNativeHighlight(node: any) {
5353
clearTimeout(hideTimeoutId);
5454

55-
// `publicInstance` => Fabric
56-
// TODO: remove this check when syncing the new version of the renderer from React to React Native.
55+
// `canonical.publicInstance` => Fabric
5756
// `canonical` => Legacy Fabric
5857
// `node` => Legacy renderer
59-
const component = node.publicInstance ?? node.canonical ?? node;
58+
const component =
59+
(node.canonical && node.canonical.publicInstance) ??
60+
// TODO: remove this check when syncing the new version of the renderer from React to React Native.
61+
node.canonical ??
62+
node;
6063
if (!component || !component.measure) {
6164
return;
6265
}

0 commit comments

Comments
 (0)