Dimensions API does not handles orientation change
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C++
- Estrellas
- 127k
- Forks
- 25.3k
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 4
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el rn791-dimensions-api-bug-reproducer obligatorio y el registro de orientación en App.tsx; gira el dispositivo iOS o el simulador y confirma la salida del evento de cambio de Dimensions. Rastrea el manejo de la API Dimensions de iOS que produce esos valores y considera completado el issue cuando width y height reflejen la orientación actual después de la rotación y el comportamiento esté cubierto por una prueba adecuada.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- react-native
- Área
- mobile
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100