Skip to content
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

refactor[renderer]: expose getInspectorDataForInstance in rendererConfig #26913

Merged

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Jun 8, 2023

Summary

This is required for the case when we have an instance and want to get inspector data for it. Such case occurs when RN's application being debugged via React DevTools.

React DevTools sends instance to RN, which then gets all auxiliary data to highlight some elements. Having getInspectorDataForInstance method exposed makes it possible to easily get current props from fiber, which then can be used to display some margins & paddings for hovered element (via props.style).

I see that getInspectorDataForInstance is being exported at the top level of the renderer, but feels like this should also be inside DevTools global hook, the same way we use it for getInspectorDataForViewAtPoint.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 8, 2023
@react-sizebot
Copy link

react-sizebot commented Jun 8, 2023

Comparing: 9100456...8b99a4f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 164.23 kB 164.23 kB = 51.73 kB 51.73 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 171.67 kB 171.67 kB = 53.97 kB 53.97 kB
facebook-www/ReactDOM-prod.classic.js = 570.12 kB 570.12 kB = 100.58 kB 100.58 kB
facebook-www/ReactDOM-prod.modern.js = 553.90 kB 553.90 kB = 97.75 kB 97.75 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 8b99a4f

@hoxyq hoxyq force-pushed the renderer/expose-get-inspector-data-for-instance branch from fa3f8bd to 8b99a4f Compare June 8, 2023 15:51
@@ -137,6 +137,7 @@ injectIntoDevTools({
version: ReactVersion,
rendererPackageName: 'react-native-renderer',
rendererConfig: {
getInspectorDataForInstance,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why its named getInspectorDataForInstance?

Should it be getInspectorDataForFiber?

@rubennorte
Copy link
Contributor

rubennorte commented Jun 9, 2023

I see that getInspectorDataForInstance is being exported at the top level of the renderer, but feels like this should also be inside DevTools global hook, the same way we use it for getInspectorDataForViewAtPoint.

Yeah, I think this makes sense for alignment with what we're doing now, but it also looks like React Native is (even before this change) abusing the DevTools renderer registration system to access information that DevTools has no use for. In other words, React Native shouldn't be doing this:

https://github.com/facebook/react-native/blob/5cc8ceeae210f2f23ef18ded7b7b614682f0d67b/packages/react-native/Libraries/Inspector/getInspectorDataForViewAtPoint.js#L32-L41

Perhaps in the future we can refactor this and implement this outside of DevTools.

In any case, this makes sense here considering what we're doing now.

@hoxyq hoxyq merged commit 21a161f into facebook:main Jun 9, 2023
@hoxyq hoxyq deleted the renderer/expose-get-inspector-data-for-instance branch June 9, 2023 09:55
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
…fig (facebook#26913)

## Summary
This is required for the case when we have an instance and want to get
inspector data for it. Such case occurs when RN's application being
debugged via React DevTools.

React DevTools sends instance to RN, which then gets all auxiliary data
to highlight some elements. Having `getInspectorDataForInstance` method
exposed makes it possible to easily get current props from fiber, which
then can be used to display some margins & paddings for hovered element
(via props.style).

I see that `getInspectorDataForInstance` is being exported at the top
level of the renderer, but feels like this should also be inside
DevTools global hook, the same way we use it for
[`getInspectorDataForViewAtPoint`](https://github.com/facebook/react-native/blob/e7d3662904e0e35e43380ee6d54859388713a592/packages/react-native/Libraries/Inspector/getInspectorDataForViewAtPoint.js).
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
…fig (#26913)

## Summary
This is required for the case when we have an instance and want to get
inspector data for it. Such case occurs when RN's application being
debugged via React DevTools.

React DevTools sends instance to RN, which then gets all auxiliary data
to highlight some elements. Having `getInspectorDataForInstance` method
exposed makes it possible to easily get current props from fiber, which
then can be used to display some margins & paddings for hovered element
(via props.style).

I see that `getInspectorDataForInstance` is being exported at the top
level of the renderer, but feels like this should also be inside
DevTools global hook, the same way we use it for
[`getInspectorDataForViewAtPoint`](https://github.com/facebook/react-native/blob/e7d3662904e0e35e43380ee6d54859388713a592/packages/react-native/Libraries/Inspector/getInspectorDataForViewAtPoint.js).

DiffTrain build for commit 21a161f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants