Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useWindowDimensions hook is triggering reversed dimensions in ipad #49511

Closed
vishnuc opened this issue Feb 19, 2025 · 4 comments
Closed

useWindowDimensions hook is triggering reversed dimensions in ipad #49511

vishnuc opened this issue Feb 19, 2025 · 4 comments

Comments

@vishnuc
Copy link

vishnuc commented Feb 19, 2025

Description

Hi , useWindowDimensions hook is triggering reversed dimensions in ipad when i change orientation. for portrait width of landscape is shown and vice versa.

Steps to reproduce

just run below code in ipad simulator

import { View, Text } from "react-native";
import { useWindowDimensions } from "react-native";

export default function ChatPage() {
  const { width } = useWindowDimensions();

  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <Text>Chat Page {width}</Text>
    </View>
  );
}

React Native Version

0.76.7

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.3
  CPU: (8) arm64 Apple M2
  Memory: 165.47 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.13.1
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.2
    path: /usr/local/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 23.0.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.7
    wanted: 0.76.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

No errors

Reproducer

https://snack.expo.dev/@adjmpw/incorrect-usewindowdimensions

Screenshots and Videos

No response

@lewiscasewell
Copy link

Is this also the same for const { width } = Dimensions.get('window')?

@vishnuc
Copy link
Author

vishnuc commented Feb 19, 2025

This one is fixed right , still I was calling const { width } = Dimensions.get('window') on expo orientation change ,, Which gives the same wrong width.

ScreenOrientation.addOrientationChangeListener((orientation) => {
  console.log(orientation);
  const width = Dimensions.get("window").width;
  Alert.alert(`${width}`);
});

@migueldaipre
Copy link
Collaborator

Duplicate of #29290. If the problem is something else, please open another issue.

@vishnuc
Copy link
Author

vishnuc commented Mar 1, 2025

No solution yet to open one ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants