Description
The following spec definition will produce a ViewProp that correctly initializes with nothing:
maxZoom?: CodegenTypes.WithDefault<CodegenTypes.Float, null>;
produces:
But when using a Double instead, the behavior is inconsistent and now forces the values to 0:
maxZoom?: CodegenTypes.WithDefault<CodegenTypes.Double, null>;
procudes:
I have tried without using "WithDefault" (ie. maxZoom?: CodegenTypes.Double) but in both cases it defaults to 0.0. This behavior is not only undocumented, but it is also inconsistent with Floats, and there are no tests for it:
https://github.com/facebook/react-native/tree/f06f9c9be678a98046531b2614e2f04c76a24942/packages/react-native-codegen/e2e/namespaced/__test_fixtures__/components
(you can see that the directory listing only shows Int and Float tests, and the Int tests aren't even testing this scenario).
I don't fully understand the codegen, so I can't submit a PR for it, but this means some really wacky hacks to try and get around the lack of an optional value. It might be good to go over all of the data types and ensure that they are nullable.
Steps to reproduce
export interface NativeProps extends ViewProps {
zoom?: CodegenTypes.WithDefault<CodegenTypes.Float, null>;
maxZoom?: CodegenTypes.WithDefault<CodegenTypes.Float, null>;
// ...
vs
export interface NativeProps extends ViewProps {
zoom?: CodegenTypes.WithDefault<CodegenTypes.Double, null>;
maxZoom?: CodegenTypes.WithDefault<CodegenTypes.Double, null>;
// ...
React Native Version
0.81.0
Affected Platforms
Build - MacOS
Output of npx @react-native-community/cli info
System:
OS: macOS 15.6
CPU: (14) arm64 Apple M4 Pro
Memory: 4.24 GB / 48.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.19.4
path: ~/.nvm/versions/node/v20.19.4/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v20.19.4/bin/yarn
npm:
version: 10.8.2
path: ~/.nvm/versions/node/v20.19.4/bin/npm
Watchman: Not Found
Managers:
CocoaPods: Not Found
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: 2025.1 AI-251.26094.121.2512.13930704
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.15
path: /usr/bin/javac
Ruby:
version: 3.3.5
path: /Users/***/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.0
wanted: 19.1.0
react-native:
installed: 0.81.0
wanted: 0.81.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.81.1 is now available (your project is running on v0.81.0).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.81.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.81.0&to=0.81.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
There is no related crash for codegen errors.
MANDATORY Reproducer
https://github.com/teslamotors/react-native-camera-kit/tree/master/example
Screenshots and Videos
No response
Description
The following spec definition will produce a ViewProp that correctly initializes with nothing:
produces:
But when using a Double instead, the behavior is inconsistent and now forces the values to 0:
procudes:
I have tried without using "WithDefault" (ie.
maxZoom?: CodegenTypes.Double) but in both cases it defaults to 0.0. This behavior is not only undocumented, but it is also inconsistent with Floats, and there are no tests for it:https://github.com/facebook/react-native/tree/f06f9c9be678a98046531b2614e2f04c76a24942/packages/react-native-codegen/e2e/namespaced/__test_fixtures__/components
(you can see that the directory listing only shows Int and Float tests, and the Int tests aren't even testing this scenario).
I don't fully understand the codegen, so I can't submit a PR for it, but this means some really wacky hacks to try and get around the lack of an optional value. It might be good to go over all of the data types and ensure that they are nullable.
Steps to reproduce
vs
React Native Version
0.81.0
Affected Platforms
Build - MacOS
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
https://github.com/teslamotors/react-native-camera-kit/tree/master/example
Screenshots and Videos
No response