react-native: Passing integer to Alert causes the program to crash

Description

When passing an integer to Alert.alert the app will stop executing the function its in, and just move on. I think it should be possible to provide integers to alerts, or at least have an error message letting you know that the issue is that you provided the wrong data type. Would also be nice if it automatically typecasted integers/floats to strings in this scenario as its only used to display it on the screen, not to do anything with the data itself.

Example: Alert.alert(“This alert will cause things to crash”, 5);

Version

0.70.5

Output of npx react-native info

info Fetching system and libraries information… System: OS: macOS 13.0.1 CPU: (10) arm64 Apple M1 Max Memory: 15.01 GB / 64.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.3.0 - ~/Desktop/Login/node_modules/.bin/node Yarn: Not Found npm: 8.19.2 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 17.0.6 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.5 => 0.70.5 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found info React Native v0.71.2 is now available (your project is running on v0.70.5). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.71.2 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.70.5 info For more info, check out “https://reactnative.dev/docs/upgrading”.

Steps to reproduce

Create an alert including a number.

Example: Alert.alert(“This alert will cause things to crash”, 5);

Snack, code example, screenshot, or link to a repository

Full on snack wont be necessary. Reproduction is done just by making an alert containing any other type than a string.

Examples of alerts that will crash: Alert.alert(“This alert will cause things to crash”, 5); Alert.alert(2.5);

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Starting from React Native 71, we support TypeScript as default and out-of-the-box, so the code can be type checked! 😄