react-native-visionos
react-native-visionos copied to clipboard
Initial `width` and `height` are inaccurate when manually setting `.defaultSize` on `RCTMainWindow`
Description
When setting a custom height and/or width on the RCTMainWindow
, the values reported by useWindowDimension
are incorrect until the window is either moved or resized.
Steps to reproduce
- Init a new project via the instructions in the readme
- Change the default window size by setting
.defaultSize(.init(width: 2000, height: 180))
onRCTMainWindow
- Log the results of
useWindowDimensions
in the app file, and note the difference between the initially logged value and window size
React Native Version
0.73.4
Affected Platforms
Other (please specify)
Output of npx react-native info
System:
OS: macOS 14.2.1
CPU: (12) arm64 Apple M2 Max
Memory: 196.42 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.5.0
path: ~/.nvm/versions/node/v20.5.0/bin/node
Yarn:
version: 4.1.0
path: ~/.nvm/versions/node/v20.5.0/bin/yarn
npm:
version: 9.8.0
path: ~/.nvm/versions/node/v20.5.0/bin/npm
Watchman:
version: 2024.01.15.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.2
- iOS 17.2
- macOS 14.2
- tvOS 17.2
- visionOS 1.0
- watchOS 10.2
Android SDK: Not Found
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode:
version: 15.2/15C500b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.4
wanted: 0.73.4
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
### Stacktrace or Logs
```text
LOG 🪵 | height: 720
LOG 🪵 | width: 1280
Reproducer
https://github.com/billyjacoby/callstack-visionos-repro/tree/window-size
Screenshots and Videos
I have very limited experience with the native library portion of React Native, but if someone wants to point me in the right direction I'm happy to try and fix this issue.
I assume the initial size just isn't being sent to the RN side of things for some reason.