undefined in buttonIndex callback showActionSheetWithOptions
See original GitHub issueHi,
I would like to open this issue because I had some trouble with my app.
ActionSheet.showActionSheetWithOptions(
{
options,
},
(i) => {
setSelectedKind(kinds[i]);
}
);
When my action sheet is displayed and I clicked on the return button of my emulator, the buttonIndex callback is triggered and I got parameter i as undefined that cause my app to crash. I thought that this parameter type was of type number: https://github.com/expo/react-native-action-sheet/blob/master/src/types.ts#L5
I also considered this pr: https://github.com/expo/react-native-action-sheet/pull/102, but I’m not sure to understand the point. Is it possible that this callback is not called if we click on the return button ? Are we obliged to put a cancel button on the action sheet to get the expected behavior ?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
@scrawllife/react-native-action-sheet - npm
showActionSheetWithOptions ( { options: options ... hardware back button is pressed the buttonIndex value is cancelButtonIndex or 'undefined' ...
Read more >exponentjs - Bountysource
When my action sheet is displayed and I clicked on the return button of my emulator, the buttonIndex callback is triggered and I...
Read more >async/await and recursion - Stack Overflow
It returns undefined because there is a path where there is no return statement. ... showActionSheetWithOptions is not async.
Read more >Javascript – async/await and recursion – iTecNote
showActionSheetWithOptions ({ title: 'Choose a value from array: ', options: object.array, }, buttonIndex => async function() { const selectedValue ...
Read more >ActionSheetIOS - React Native
static showActionSheetWithOptions(options, callback). Display an iOS action ... showActionSheetWithOptions( ... if (buttonIndex === 1) {
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 issue has been resolved in version 3.12.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
What i wanted to say is just add the
undefined
type in typescript. Because thecancelButtonIndex
is just acting at runtime. But yes, if you specify cancelButton it should work as expected !