How can you measure the height of a react-native element if you only have the ref
?
I see NativeMethodsMixin but it's not clear how to implement it.
I've tried including it as:
import { NativeMethodsMixin } from 'react-native';
class Foo extends Component {
mixins: [NativeMethodsMixin]
measure(ref) {
console.log(NativeMethodsMixin.measure(ref));
}
...
}
but the app complains that NativeMethodsMixin
is undefined.
If I go the RCTUIManager
route:
import { NativeModules } from 'react-native';
const RCTUIManager = NativeModules.UIManager;
class Foo extends Component {
measure(ref) {
const height = RCTUIManager.measure(ref, (x, y, width, height, pageX, pageY) => height));
console.log(height);
}
...
}
then I get an error: Uncaught TypeError: Converting circular structure to JSON
I just want to get the height of that ref
. What am I missing?