RCTUIManager.measure not working on Android
See original GitHub issueDescription
RCTUIManager.measure
is not working on Android
. Trying this.refs.myRef.measure()
doesn’t give any results either.
Reproduction
import { findNodeHandle } from 'react-native';
const RCTUIManager = require('NativeModules').UIManager;
RCTUIManager.measure(findNodeHandle(this.refs.myRef), (x, y, width, height, pageX, pageY) => {
// Returns valid values on iOS but undefined on Android
});
Additional Information
- React Native version: 0.42.0
- Platform: Android
- Operating System: MacOS
- Dev tools: Android Studio 2.3
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:17 (6 by maintainers)
Top Results From Across the Web
UIManager.measure dose not work on Android #22443 - GitHub
It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the...
Read more >React Native android crash UIManager - Stack Overflow
I made an android app with Expo and React-Native and since I upgraded to // package.json "expo": "^20.0.0", "react": "16.0.0-alpha.12", ...
Read more >A Keyboard Avoiding View for React Native in 2021
A repeating theme I've found in KeyboardAvoidingView issues is the presence of React Navigation in a React Native project - so if you...
Read more >Prerequisites for Libraries - React Native
The following steps will help ensure your modules and components are ready for the New Architecture.
Read more >react-native-svg - npm
Troubleshooting. Problems with Proguard. When Proguard is enabled (which it is by default for Android release builds), it causes runtime error.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So
style={{opacity: 1}}
is what I used until I understood the issue.Collapsable property is explained in https://facebook.github.io/react-native/docs/view.html#collapsable
However, some of UIManager functions such as
measure
expect to find a native view; and when it can’t it returnsundefined
values instead of throwing an error. Really it would be better to throw an error. React unfortunately is not intelligent to know you would be measuring the view in the first place.Putting an explicit style is one way to disable the optimization; because now the view has to be created with special drawing properties. But the real fix is putting
collapsable={false}
on the view you will be measuring to disable the optimization by the documentation.Adding
style={{opacity: 1}}
did the trick. Thanks a lot!Referring to your comment in #9382, what exactly do you mean by collapsable property?
Now I always force it to be created with collapsable property.
Although an annoyance, should I just follow your lead and close out this issue?