Last active
May 16, 2023 15:09
-
-
Save phuochau/af26c22b2b69bf1f7a3a389912d8dbd3 to your computer and use it in GitHub Desktop.
Best way to measure layout of view in React Native (works in both iOS & Android)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
findNodeHandle | |
} from 'react-native' | |
this.childItem.measureLayout(findNodeHandle(this.containerWrapper), (x, y, width, height) => { | |
console.log('got measurement', x, y, width, height) | |
}) | |
// example render | |
<container-wrapper ref={ref => this.containerWrapper = ref}> | |
<item ref={ref => this.childItem = ref } /> | |
</container-wrapper> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks,
didn't know about this possibility.
It really very useful