Description
Description
Dimensions API always return portrait mode values (height > width) even if app was started in landscape mode.
Try to rotate device and check console output - height > width always.
Steps to reproduce
-
npx @react-native-community/cli@latest init rn791
-
cd rn791
-
yarn
-
cd ios && pod install
-
add next lines of code to App.tsx
`useEffect(() => {
const updateOrientation = () => {
const {height, width} = Dimensions.get('window');
const orientation = width > height ? 'landscape' : 'portrait';
console.log('new orientation: ', orientation);
};updateOrientation();
const subscription = Dimensions.addEventListener(
'change',
updateOrientation,
);return () => {
subscription?.remove();
};
}, []);`
React Native Version
0.79.1
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System:
OS: macOS 15.4.1
CPU: (10) arm64 Apple M1 Pro
Memory: 104.02 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.12.0
path: ~/.nvm/versions/node/v22.12.0/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v22.12.0/bin/yarn
npm:
version: 10.9.0
path: ~/.nvm/versions/node/v22.12.0/bin/npm
Watchman:
version: 2024.11.25.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.4
- iOS 18.4
- macOS 15.4
- tvOS 18.4
- visionOS 2.4
- watchOS 11.4
Android SDK: Not Found
IDEs:
Android Studio: 2024.3 AI-243.24978.46.2431.13208083
Xcode:
version: 16.3/16E140
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.13
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 18.0.0
wanted: 18.0.0
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.79.1
wanted: 0.79.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
no stacktrace
MANDATORY Reproducer
https://github.com/roman-zaitsev/rn791-dimensions-api-bug-reproducer
Screenshots and Videos
No response