Is there an api to get the height and width of an element in React Native using a ref?
I'm not interested in the window or screen dimensions, and I understand you can use onLayout, but wanted to double check to make sure there's no api for height and width when using a ref.
Some additional verbose elaboration:
In ReactJS, clientHeight and clientWidth works, but not in React Native.
const ref = React.useRef();
const height = ref.current.clientHeight;
const width= ref.current.clientWidth;
return <div ref={ref} />;
On React Native, you can use onLayout, but is there a method for a ref?
<View
onLayout={(event) => {
const dimensions = event.nativeEvent.layout;
const {width, height} = dimensions;
}}
>
</View>