Alert not working ('buttons.slice' is undefined)
See original GitHub issueThe Alert function no longer works in my project. I’m attempting to create an alert when the user encounters an error, but instead a JS error is thrown.
TypeError: buttons.slice is not a function. (In 'buttons.slice(0, 3)', 'buttons.slice' is undefined)
at alert(/Users/craig/Dev/oddBox/node_modules/react-native/Libraries/Alert/Alert.js:69:24)
at tryCatch(/Users/craig/Dev/oddBox/node_modules/regenerator-runtime/runtime.js:45:44)
at invoke(/Users/craig/Dev/oddBox/node_modules/regenerator-runtime/runtime.js:271:30)
at tryCatch(/Users/craig/Dev/oddBox/node_modules/regenerator-runtime/runtime.js:45:44)
at invoke(/Users/craig/Dev/oddBox/node_modules/regenerator-runtime/runtime.js:135:28)
at Promise.resolve.then$argument_1(/Users/craig/Dev/oddBox/node_modules/regenerator-runtime/runtime.js:147:19)
at tryCallOne(/Users/craig/Dev/oddBox/node_modules/promise/setimmediate/core.js:37:14)
at setImmediate$argument_0(/Users/craig/Dev/oddBox/node_modules/promise/setimmediate/core.js:123:25)
at _callTimer(/Users/craig/Dev/oddBox/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14)
at _callImmediatesPass(/Users/craig/Dev/oddBox/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17)
at callImmediates(/Users/craig/Dev/oddBox/node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30)
at callImmediates([native code])
at flushedQueue([native code])
at invokeCallbackAndReturnFlushedQueue([native code])
React Native version:
System:
OS: macOS Mojave 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 157.77 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.1 - /usr/local/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.12.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 25, 26, 28
Build Tools: 23.0.1, 25.0.0, 26.0.1, 26.0.2, 26.0.3, 28.0.3
System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native: 0.59.4
Steps To Reproduce
- Create alert function
export const createAlert = (title, msg) => {
Alert.alert(
title,
msg,
[
{ text: "OK", onPress: () => console.log("OK Pressed") }
],
{ cancelable: true }
);
}
- Call function:
createAlert("Error", "I am an error")
Describe what you expected to happen: Expect the alert to show on the device, but instead the exception is caught by Sentry.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:10
Top Results From Across the Web
React native buttons.slice is not a function - Stack Overflow
I'm trying to print a variable using Alert.alert it might be me but I'm not able ...
Read more >How to Show Alert in React Native
Try uninstalling the cli and run the cli using npx. This will make a project structure with an index file named App. js...
Read more >JavaScript undefined Property - W3Schools
The undefined property indicates that a variable has not been assigned a value, or not declared at all. ... undefined() is an ECMAScript1...
Read more >Alert - Deque University
Note: The code below is functional only in the context of the complete JavaScript file. In the @alert section: function createAlert(message) { var...
Read more >https://eddir.alsde.edu/EdDir/Scripts/bootstrap.mi...
parentNode)\n },\n\n jQueryDetection() {\n if (typeof $ === 'undefined') ... triggerChangeEvent = false\n }\n } else {\n // if it's not a radio...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is worked for me Alert.alert(‘Error’, ‘Please enter some text’, [ { text: “OK”, onPress: () => console.log(“OK Pressed”) } ], { cancelable: true });
Maybe you forgot the second parameter.
Alert.alert( “title here”, “”, // empty string [ { text: “OK”, onPress: () => console.log(“OK Pressed”) } ], { cancelable: true } );