Fix inspecting for non-fabric
Summary: Changelog: [Internal] I think this started to break when https://github.com/facebook/react/pull/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
This commit is contained in:
Родитель
3681df2878
Коммит
e047eed2eb
|
@ -125,11 +125,11 @@ export default function DevtoolsOverlay({
|
|||
getInspectorDataForViewAtPoint(inspectedView, x, y, viewData => {
|
||||
const {touchedViewTag, closestInstance, frame} = viewData;
|
||||
if (closestInstance != null || touchedViewTag != null) {
|
||||
// We call `selectNode` for both non-fabric(viewTag) and fabric(instance),
|
||||
// this makes sure it works for both architectures.
|
||||
agent.selectNode(findNodeHandle(touchedViewTag));
|
||||
if (closestInstance != null) {
|
||||
// Fabric
|
||||
agent.selectNode(closestInstance);
|
||||
} else {
|
||||
agent.selectNode(findNodeHandle(touchedViewTag));
|
||||
}
|
||||
setInspected({
|
||||
frame,
|
||||
|
|
|
@ -142,12 +142,11 @@ class Inspector extends React.Component<
|
|||
// Sync the touched view with React DevTools.
|
||||
// Note: This is Paper only. To support Fabric,
|
||||
// DevTools needs to be updated to not rely on view tags.
|
||||
if (this.state.devtoolsAgent) {
|
||||
const agent = this.state.devtoolsAgent;
|
||||
if (agent) {
|
||||
agent.selectNode(findNodeHandle(touchedViewTag));
|
||||
if (closestInstance != null) {
|
||||
// Fabric
|
||||
this.state.devtoolsAgent.selectNode(closestInstance);
|
||||
} else if (touchedViewTag != null) {
|
||||
this.state.devtoolsAgent.selectNode(findNodeHandle(touchedViewTag));
|
||||
agent.selectNode(closestInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче