-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Measuring a view without an onLayout returns an empty set of coordinates #19591
Comments
This is also happening in my end using react-native 0.56 |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
It's still happening on react-native@0.57 |
@mmazzarolo Its not exactly that case, but I have similar problem. Is it possible to set onLayout directly through ref, and not with property in JSX? I want to get ref to external component and show popup menu tied up / stick to external component. And update position of popup whenever position of external component changes. |
Reproducible on react-native@0.57 with or without onLayout! |
This is expected behaviour (tho maybe it's possible to print a warning to make it more explicit?). On Android, Views that are only used for layout are removed from the hierarchy to save memory and speed. You need to set Setting |
Description
Measuring an Android View using
ref.measureInWindow
returns an empty set of coordinates if theonLayout
prop of the View is not set.The issue arises only when the View wraps some specific component like
TouchableWithoutFeedback
,TouchableNativeFeedback
andTouchableOpacity
.Environment
Environment:
Packages: (wanted => installed)
Steps to Reproduce
Create a new app using CRNA/Expo and change
App.js
like this:I also created an Expo Snack.
Expected Behavior
Pressing the red square should always print the correct measures on consoles, even when its
onLayout
prop isundefined
like in the example.The correct printed layout should be something like:
Actual Behavior
Pressing the red square prints the correct measures on consoles only when you set an
onLayout
(try settingonLayout={() => null}
and you will see that it will works correctly).If you don't se the
onLayout
, the result will be the following:Image recap
The text was updated successfully, but these errors were encountered: