-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Open
Labels
Description
Description
Trying to call .measure()
on a View
ref while strict types are enabled results in TypeScript errors. As soon as the strict types are disabled, the error goes away.
Steps to reproduce
Try and call .measure()
on a View
ref:
const viewRef = useRef<View>(null);
useEffect(() => {
if (viewRef.current) {
viewRef.current.measure(() => {});
}
}, []);
Note: This is NOT reproducible in ref
prop:
<View
ref={viewRef => {
if (viewRef.current) {
// Works
viewRef.current.measure(() => {});
}
}}
/>
React Native Version
0.82.0
Affected Platforms
Build - MacOS
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.7.1
CPU: (10) arm64 Apple M1 Max
Memory: 372.50 MB / 64.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.3.0
path: /usr/local/bin/node
Yarn:
version: 4.10.3
path: /usr/local/bin/yarn
npm: Not Found
Watchman: Not Found
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.0
- iOS 26.0
- macOS 26.0
- tvOS 26.0
- visionOS 26.0
- watchOS 26.0
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 26.0.1/17A400
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.1
wanted: 19.1.1
react-native:
installed: 0.82.0
wanted: 0.82.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
wojciech.maj@MacBook-Pro ReproducerApp % yarn tsc
App.tsx:33:23 - error TS2339: Property 'measure' does not exist on type '(props: Omit<Readonly<Omit<Readonly<{ onAccessibilityAction?: ((event: Readonly<{ bubbles: boolean | undefined; cancelable: boolean | undefined; currentTarget: number | ReactNativeElement; ... 12 more ...; type: string | undefined; }>) => unknown) | undefined; onAccessibilityTap?: (() => unknown) | undefined; onLayo...'.
33 viewRef.current.measure(() => {});
~~~~~~~
Found 1 error in App.tsx:33
MANDATORY Reproducer
https://github.com/wojtekmaj/react-native-missing-strict-types
Screenshots and Videos
