iOS WebKit: Window dimensions (useWindowDimensions) behave erratically when zooming
Author: qwertychouskieCreated Jun 8, 2025Updated Sep 30, 2026
Labelsbug
Is there an existing issue for this?
- I have searched the existing issues
Describe the issue
Supposedly this was fixed in https://github.com/necolas/react-native-web/issues/1905, but I am still running into this issue. When I pinch-to-zoom on iOS Safari, elements that use the dimensions from useWindowDimensions() jump around, and a look at debug logging I added confirms the values are jumping around. Interestingly, useSafeAreaFrame() does not appear to have this issue.
https://github.com/user-attachments/assets/64da6bcd-0032-43fa-b508-d7236a5cc8f2
Expected behavior
The reported window dimensions should be accurate and stable.
Steps to reproduce
- Pinch-to-zoom on iOS Safari
Test case
My code for reference:
import { EdgeInsets, useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context"
import { Platform, useWindowDimensions } from "react-native";
export default (): { width: number, height: number, insets: EdgeInsets } => {
// Workaround https://github.com/facebook/react-native/issues/41918
const { height, width } = Platform.OS === 'android'? useSafeAreaFrame() : useWindowDimensions();
console.warn(`width: ${width}, height: ${height}`)
return {
height,
width,
insets: useSafeAreaInsets()
}
}Source: necolas/react-native-web