From 61d8f6f7ba447658f818761f199941262a6aac2c Mon Sep 17 00:00:00 2001 From: "hoxyq (Meta Employee)" Date: Thu, 26 Sep 2024 08:08:53 -0700 Subject: [PATCH] fix: use public instance in Fiber renderer and expose it from getInspectorDataForViewAtPoint (#31068) Summary: React DevTools no longer operates with just Fibers, it now builds its own Shadow Tree, which represents the tree on the Host (Fabric on Native, DOM on Web). We have to keep track of public instances for a select-to-inspect feature. We've recently changed this logic in https://github.com/facebook/react/pull/30831, and looks like we've been incorrectly getting a public instance for Fabric case. Not only this, turns out that all `getInspectorData...` APIs are returning Fibers, and not public instances. I have to expose it, so that React DevTools can correctly identify the element, which was selected. Changes for React Native are in [D63421463](https://www.internalfb.com/diff/D63421463) DiffTrain build for commit https://github.com/facebook/react/commit/d66fa02a303fc53d901bdb0d7bbdaec3e6774b19. Reviewed By: poteto Differential Revision: D63453667 Pulled By: hoxyq --- .../react-native/Libraries/Renderer/shims/ReactNativeTypes.js | 3 ++- .../Libraries/__tests__/__snapshots__/public-api-test.js.snap | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js b/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js index dce315677107bb..4cdb435dbe5b88 100644 --- a/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/packages/react-native/Libraries/Renderer/shims/ReactNativeTypes.js @@ -7,7 +7,7 @@ * @noformat * @nolint * @flow strict - * @generated SignedSource<<3eb929731c259569c7af3b6479e486fe>> + * @generated SignedSource<> */ import type { @@ -180,6 +180,7 @@ export type TouchedViewDataAtPoint = $ReadOnly<{ width: number, height: number, }>, + closestPublicInstance?: PublicInstance, ...InspectorData, }>; diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 88b07421e9d12b..8910afc37cacee 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -7838,6 +7838,7 @@ export type TouchedViewDataAtPoint = $ReadOnly<{ width: number, height: number, }>, + closestPublicInstance?: PublicInstance, ...InspectorData, }>; export type RenderRootOptions = {