-
Notifications
You must be signed in to change notification settings - Fork 47.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean interface for public instances between React and React Native #26416
Merged
sammy-SC
merged 2 commits into
facebook:main
from
rubennorte:clean-interface-between-react-and-react-native
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ import {HostComponent} from 'react-reconciler/src/ReactWorkTags'; | |
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; | ||
import {enableGetInspectorDataForInstanceInProduction} from 'shared/ReactFeatureFlags'; | ||
import {getClosestInstanceFromNode} from './ReactNativeComponentTree'; | ||
import {getInternalInstanceHandleFromPublicInstance} from './ReactFabricPublicInstanceUtils'; | ||
import {getNodeFromPublicInstance} from './ReactFabricPublicInstanceUtils'; | ||
import {getNodeFromInternalInstanceHandle} from './ReactNativePublicCompat'; | ||
|
||
const emptyObject = {}; | ||
|
@@ -196,12 +196,7 @@ function getInspectorDataForViewAtPoint( | |
if (__DEV__) { | ||
let closestInstance = null; | ||
|
||
const fabricInstanceHandle = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This level of indirection was unnecessary. |
||
getInternalInstanceHandleFromPublicInstance(inspectedView); | ||
const fabricNode = | ||
fabricInstanceHandle != null | ||
? getNodeFromInternalInstanceHandle(fabricInstanceHandle) | ||
: null; | ||
const fabricNode = getNodeFromPublicInstance(inspectedView); | ||
if (fabricNode) { | ||
// For Fabric we can look up the instance handle directly and measure it. | ||
nativeFabricUIManager.findNodeAtPoint( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between a Node and a PublicInstance (i.e. why doesn't the existing
getNodeFromInternalInstanceHandle
work)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node is the shadow node (which is a host object created by Fabric in native). Public instance is the instance of
ReactFabricHostComponent
that's provided via refs and has the methods that users can invoke directly (likemeasure
andfocus
, but will evolve to have things likechildren
,getBoundingClientRect
, etc. as per my proposal).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if these are supposed to be different things? I think I would expect a Node to be a HostComponent but I don't have a ton of context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're the same concept on Web but not on RN. If we made them to be the same we'd have to implement the methods of the public instance in native, which isn't very convenient.
We could use another refactor to clean up naming, improve docs, etc. I can give it a try after these 2 PRs.