Skip to content

Commit e047eed

Browse files
tyao1facebook-github-bot
authored andcommitted
Fix inspecting for non-fabric
Summary: Changelog: [Internal] I think this started to break when facebook/react#25441 was synced to RN. Before, `closestInstance` would only be non-null under Fabric, after it could be non-null in both. And we were using `closestInstance` to determine which data to send to `selectNode` in devtools. This diff makes a change to call `selectNode` once for non-fabric and once for fabric, one of them would not send anything to devtools frontend, this would make sure it works for both platforms. Reviewed By: mondaychen Differential Revision: D41366466 fbshipit-source-id: fcf30d03e443f6fa067782cd31b7cfd2e0cd841e
1 parent 3681df2 commit e047eed

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Libraries/Inspector/DevtoolsOverlay.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ export default function DevtoolsOverlay({
125125
getInspectorDataForViewAtPoint(inspectedView, x, y, viewData => {
126126
const {touchedViewTag, closestInstance, frame} = viewData;
127127
if (closestInstance != null || touchedViewTag != null) {
128+
// We call `selectNode` for both non-fabric(viewTag) and fabric(instance),
129+
// this makes sure it works for both architectures.
130+
agent.selectNode(findNodeHandle(touchedViewTag));
128131
if (closestInstance != null) {
129-
// Fabric
130132
agent.selectNode(closestInstance);
131-
} else {
132-
agent.selectNode(findNodeHandle(touchedViewTag));
133133
}
134134
setInspected({
135135
frame,

Libraries/Inspector/Inspector.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,11 @@ class Inspector extends React.Component<
142142
// Sync the touched view with React DevTools.
143143
// Note: This is Paper only. To support Fabric,
144144
// DevTools needs to be updated to not rely on view tags.
145-
if (this.state.devtoolsAgent) {
145+
const agent = this.state.devtoolsAgent;
146+
if (agent) {
147+
agent.selectNode(findNodeHandle(touchedViewTag));
146148
if (closestInstance != null) {
147-
// Fabric
148-
this.state.devtoolsAgent.selectNode(closestInstance);
149-
} else if (touchedViewTag != null) {
150-
this.state.devtoolsAgent.selectNode(findNodeHandle(touchedViewTag));
149+
agent.selectNode(closestInstance);
151150
}
152151
}
153152

0 commit comments

Comments
 (0)