Home > OS >  How to get dimensions of window when using @react-navigation/native-stack and presentation: 'mo
How to get dimensions of window when using @react-navigation/native-stack and presentation: 'mo

Time:02-15

I am trying to use @react-navigation/native-stack and presentation: 'modal' to get more native feel on tablets. My problem is I did not find any way how to get dimensions of modal window. I tried both useWindowDimensions() and Dimensions.get('window/screen') but I always get size of whole app window, not just the modal window size.

Is there any way how to do that?

Illustration

CodePudding user response:

if u cant find something u can always use "onLayout", juts put t on wrapper View in modal

<View style={{flex:1}} onLayout={(event: LayoutChangeEvent) => {
  // event.nativeEvent.layout.width
  // event.nativeEvent.layout.height
}}>
</View>
  • Related