Description
Description
Given the provided reproduction with Expo Go, the Switch component renders as turned on when toggled, even though the onValueChange handler sets the state to false, and the value
prop is hardcoded to false
.
Steps to reproduce
Follow the provided Expo Snack, choose "My Device" and scan the QR code.
https://snack.expo.dev/@nathan.l.kramer/ranting-indigo-salsa
Once loaded, tap the Switch component. Notice that it toggles to On, despite me never setting the value
prop to true (it is hardcoded to false).
This is a more extreme version of the bug that is plagueing me where I am using the isEnabled
state as the value
prop, and despite never setting it to true the switch renders as toggled on in the same way.
The intention of the snack is to emulate an asynchronous request that returns false for some reason, indicating that the toggle could not be turned on. The behaviour currently turns it on anyway.
NOTE: The issue does not reproduce in the web mode of the Expo Snack.
React Native Version
0.78.0
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 15.3.1
CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Memory: 251.09 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.15.0
path: ~/.nvm/versions/node/v20.15.0/bin/node
Yarn: Not Found
npm:
version: 10.7.0
path: ~/.nvm/versions/node/v20.15.0/bin/npm
Watchman:
version: 2024.09.09.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/nathankramer/.rbenv/shims/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: 2022.3 AI-223.8836.35.2231.10811636
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.1
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /Users/nathankramer/.rbenv/shims/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.6
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
info React Native v0.78.0 is now available (your project is running on v0.76.7).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.78.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.76.7&to=0.78.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
No relevant stacktrace.
Reproducer
https://snack.expo.dev/@nathan.l.kramer/ranting-indigo-salsa
Screenshots and Videos
No response